From c286d65a4db083caf43ec32fa9241865aa1293d2 Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 9 Feb 2017 21:12:26 +0000 Subject: MFC r305483,r306030,r306031,r306033,r306036: r305483: Fix tests/sys/kqueue NetBSD tests on 32-bit platforms by using proper format specifier for pointers when printing them out with printf(3) Pointyhat to: ngie r306030: Port vnode_leak_test:main to FreeBSD Use a simpler way of dumping kern.maxvnodes, i.e. `sysctl -n kern.maxvnodes` The awk filtering method employed in NetBSD doesn't work on FreeBSD r306031: Port contrib/netbsd-tests/fs/h_funcs.subr to FreeBSD Use kldstat -m to determine whether or not a filesystem is loaded. This works well with tmpfs, ufs, and zfs r306033: Port sizes_test and statvfs_test to FreeBSD Similar to r306030, use a simpler method for getting the value of `hw.pagesize`, i.e. `sysctl -n hw.pagesize`. The awk filtering method doesn't work on FreeBSD r306036: Port to mknod_test and readdir_test to FreeBSD The `mknod p` command doesn't exist on FreeBSD, like on NetBSD. Use mkfifo instead to create named pipes (FIFOs). --- contrib/netbsd-tests/fs/h_funcs.subr | 12 ++++++++++++ contrib/netbsd-tests/fs/tmpfs/t_mknod.sh | 16 ++++++++++++++++ contrib/netbsd-tests/fs/tmpfs/t_readdir.sh | 8 ++++++++ contrib/netbsd-tests/fs/tmpfs/t_sizes.sh | 8 ++++++++ contrib/netbsd-tests/fs/tmpfs/t_statvfs.sh | 8 ++++++++ contrib/netbsd-tests/fs/tmpfs/t_vnode_leak.sh | 8 ++++++++ contrib/netbsd-tests/kernel/kqueue/read/t_fifo.c | 4 ++++ contrib/netbsd-tests/kernel/kqueue/read/t_file.c | 4 ++++ contrib/netbsd-tests/kernel/kqueue/read/t_pipe.c | 4 ++++ contrib/netbsd-tests/kernel/kqueue/read/t_ttypty.c | 4 ++++ contrib/netbsd-tests/kernel/kqueue/t_proc1.c | 4 ++++ contrib/netbsd-tests/kernel/kqueue/t_sig.c | 4 ++++ 12 files changed, 84 insertions(+) diff --git a/contrib/netbsd-tests/fs/h_funcs.subr b/contrib/netbsd-tests/fs/h_funcs.subr index 1216aaf..21bdd97 100644 --- a/contrib/netbsd-tests/fs/h_funcs.subr +++ b/contrib/netbsd-tests/fs/h_funcs.subr @@ -45,6 +45,15 @@ require_fs() { # if we have autoloadable modules, just assume the file system atf_require_prog sysctl + # Begin FreeBSD + if true; then + if kldstat -m ${name}; then + found=yes + else + found=no + fi + else + # End FreeBSD autoload=$(sysctl -n kern.module.autoload) [ "${autoload}" = "1" ] && return 0 @@ -57,6 +66,9 @@ require_fs() { fi shift done + # Begin FreeBSD + fi + # End FreeBSD [ ${found} = yes ] || \ atf_skip "The kernel does not include support the " \ "\`${name}' file system" diff --git a/contrib/netbsd-tests/fs/tmpfs/t_mknod.sh b/contrib/netbsd-tests/fs/tmpfs/t_mknod.sh index 62c7cce..037dc16 100755 --- a/contrib/netbsd-tests/fs/tmpfs/t_mknod.sh +++ b/contrib/netbsd-tests/fs/tmpfs/t_mknod.sh @@ -106,7 +106,15 @@ pipe_body() { test_mount umask 022 + # Begin FreeBSD + if true; then + atf_check -s eq:0 -o empty -e empty mkfifo pipe + else + # End FreeBSD atf_check -s eq:0 -o empty -e empty mknod pipe p + # Begin FreeBSD + fi + # End FreeBSD eval $(stat -s pipe) [ ${st_mode} = 010644 ] || atf_fail "Invalid mode" @@ -124,7 +132,15 @@ pipe_kqueue_body() { umask 022 atf_check -s eq:0 -o empty -e empty mkdir dir + # Begin FreeBSD + if true; then + echo 'mkfifo dir/pipe' | kqueue_monitor 1 dir + else + # End FreeBSD echo 'mknod dir/pipe p' | kqueue_monitor 1 dir + # Begin FreeBSD + fi + # End FreeBSD kqueue_check dir NOTE_WRITE test_unmount diff --git a/contrib/netbsd-tests/fs/tmpfs/t_readdir.sh b/contrib/netbsd-tests/fs/tmpfs/t_readdir.sh index 6f5dc3e..272c749 100755 --- a/contrib/netbsd-tests/fs/tmpfs/t_readdir.sh +++ b/contrib/netbsd-tests/fs/tmpfs/t_readdir.sh @@ -59,7 +59,15 @@ types_body() { atf_check -s eq:0 -o empty -e empty ln -s reg lnk atf_check -s eq:0 -o empty -e empty mknod blk b 0 0 atf_check -s eq:0 -o empty -e empty mknod chr c 0 0 + # Begin FreeBSD + if true; then + atf_check -s eq:0 -o empty -e empty mkfifo fifo + else + # End FreeBSD atf_check -s eq:0 -o empty -e empty mknod fifo p + # Begin FreeBSD + fi + # End FreeBSD atf_check -s eq:0 -o empty -e empty \ $(atf_get_srcdir)/h_tools sockets sock diff --git a/contrib/netbsd-tests/fs/tmpfs/t_sizes.sh b/contrib/netbsd-tests/fs/tmpfs/t_sizes.sh index 9673b91..35abe8a 100755 --- a/contrib/netbsd-tests/fs/tmpfs/t_sizes.sh +++ b/contrib/netbsd-tests/fs/tmpfs/t_sizes.sh @@ -54,7 +54,15 @@ big_head() { big_body() { test_mount -o -s10M + # Begin FreeBSD + if true; then + pagesize=$(sysctl -n hw.pagesize) + else + # End FreeBSD pagesize=$(sysctl hw.pagesize | cut -d ' ' -f 3) + # Begin FreeBSD + fi + # End FreeBSD eval $($(atf_get_srcdir)/h_tools statvfs . | sed -e 's|^f_|cf_|') cf_bused=$((${cf_blocks} - ${cf_bfree})) diff --git a/contrib/netbsd-tests/fs/tmpfs/t_statvfs.sh b/contrib/netbsd-tests/fs/tmpfs/t_statvfs.sh index 21290b6..d0e7ac2 100755 --- a/contrib/netbsd-tests/fs/tmpfs/t_statvfs.sh +++ b/contrib/netbsd-tests/fs/tmpfs/t_statvfs.sh @@ -38,7 +38,15 @@ values_head() { values_body() { test_mount -o -s10M + # Begin FreeBSD + if true; then + pagesize=$(sysctl -n hw.pagesize) + else + # End FreeBSD pagesize=$(sysctl hw.pagesize | cut -d ' ' -f 3) + # Begin FreeBSD + fi + # End FreeBSD eval $($(atf_get_srcdir)/h_tools statvfs .) [ ${pagesize} -eq ${f_bsize} ] || \ atf_fail "Invalid bsize" diff --git a/contrib/netbsd-tests/fs/tmpfs/t_vnode_leak.sh b/contrib/netbsd-tests/fs/tmpfs/t_vnode_leak.sh index c505ffd..4630a7c 100755 --- a/contrib/netbsd-tests/fs/tmpfs/t_vnode_leak.sh +++ b/contrib/netbsd-tests/fs/tmpfs/t_vnode_leak.sh @@ -36,7 +36,15 @@ main_head() { } main_body() { echo "Lowering kern.maxvnodes to 2000" + # Begin FreeBSD + if true; then + sysctl -n kern.maxvnodes > oldvnodes + else + # End FreeBSD sysctl kern.maxvnodes | awk '{ print $3; }' >oldvnodes + # Begin FreeBSD + fi + # End FreeBSD atf_check -s eq:0 -o ignore -e empty sysctl -w kern.maxvnodes=2000 test_mount -o -s$(((4000 + 2) * 4096)) diff --git a/contrib/netbsd-tests/kernel/kqueue/read/t_fifo.c b/contrib/netbsd-tests/kernel/kqueue/read/t_fifo.c index 5908547..19c7b02 100644 --- a/contrib/netbsd-tests/kernel/kqueue/read/t_fifo.c +++ b/contrib/netbsd-tests/kernel/kqueue/read/t_fifo.c @@ -78,7 +78,11 @@ ATF_TC_BODY(fifo, tc) RL(n = kevent(kq, NULL, 0, event, 1, NULL)); (void)printf("kevent num %d filt %d flags: %#x, fflags: %#x, " +#ifdef __FreeBSD__ + "data: %" PRIdPTR "\n", n, event[0].filter, event[0].flags, +#else "data: %" PRId64 "\n", n, event[0].filter, event[0].flags, +#endif event[0].fflags, event[0].data); ATF_REQUIRE_EQ(event[0].filter, EVFILT_READ); diff --git a/contrib/netbsd-tests/kernel/kqueue/read/t_file.c b/contrib/netbsd-tests/kernel/kqueue/read/t_file.c index 2335172..80479af 100644 --- a/contrib/netbsd-tests/kernel/kqueue/read/t_file.c +++ b/contrib/netbsd-tests/kernel/kqueue/read/t_file.c @@ -111,7 +111,11 @@ ATF_TC_BODY(file, tc) num += n; (void)printf("kevent num %d flags: %#x, fflags: %#x, data: " +#ifdef __FreeBSD__ + "%" PRIdPTR "\n", n, event[0].flags, event[0].fflags, +#else "%" PRId64 "\n", n, event[0].flags, event[0].fflags, +#endif event[0].data); if (event[0].data < 0) diff --git a/contrib/netbsd-tests/kernel/kqueue/read/t_pipe.c b/contrib/netbsd-tests/kernel/kqueue/read/t_pipe.c index d8e05f2..2cdd015 100644 --- a/contrib/netbsd-tests/kernel/kqueue/read/t_pipe.c +++ b/contrib/netbsd-tests/kernel/kqueue/read/t_pipe.c @@ -67,7 +67,11 @@ ATF_TC_BODY(pipe, tc) RL(n = kevent(kq, NULL, 0, event, 1, NULL)); (void)printf("kevent num %d flags: %#x, fflags: %#x, data: " +#ifdef __FreeBSD__ + "%" PRIdPTR "\n", n, event[0].flags, event[0].fflags, event[0].data); +#else "%" PRId64 "\n", n, event[0].flags, event[0].fflags, event[0].data); +#endif RL(n = read(fds[0], buffer, event[0].data)); buffer[n] = '\0'; diff --git a/contrib/netbsd-tests/kernel/kqueue/read/t_ttypty.c b/contrib/netbsd-tests/kernel/kqueue/read/t_ttypty.c index 3a42fd3..57ccf92 100644 --- a/contrib/netbsd-tests/kernel/kqueue/read/t_ttypty.c +++ b/contrib/netbsd-tests/kernel/kqueue/read/t_ttypty.c @@ -103,7 +103,11 @@ h_check(bool check_master) RL(n = kevent(kq, NULL, 0, event, 1, NULL)); (void)printf("kevent num %d filt %d flags: %#x, fflags: %#x, " +#ifdef __FreeBSD__ + "data: %" PRIdPTR "\n", n, event[0].filter, event[0].flags, +#else "data: %" PRId64 "\n", n, event[0].filter, event[0].flags, +#endif event[0].fflags, event[0].data); ATF_REQUIRE_EQ(event[0].filter, EVFILT_READ); diff --git a/contrib/netbsd-tests/kernel/kqueue/t_proc1.c b/contrib/netbsd-tests/kernel/kqueue/t_proc1.c index e755309..bf17749 100644 --- a/contrib/netbsd-tests/kernel/kqueue/t_proc1.c +++ b/contrib/netbsd-tests/kernel/kqueue/t_proc1.c @@ -138,7 +138,11 @@ ATF_TC_BODY(proc1, tc) printf(" NOTE_FORK"); } if (event[0].fflags & NOTE_CHILD) +#ifdef __FreeBSD__ + printf(" NOTE_CHILD, parent = %" PRIdPTR, event[0].data); +#else printf(" NOTE_CHILD, parent = %" PRId64, event[0].data); +#endif printf("\n"); } diff --git a/contrib/netbsd-tests/kernel/kqueue/t_sig.c b/contrib/netbsd-tests/kernel/kqueue/t_sig.c index 4fc0758..e367c41 100644 --- a/contrib/netbsd-tests/kernel/kqueue/t_sig.c +++ b/contrib/netbsd-tests/kernel/kqueue/t_sig.c @@ -117,7 +117,11 @@ ATF_TC_BODY(sig, tc) if (n == 0) continue; +#ifdef __FreeBSD__ + (void)printf("sig: kevent flags: 0x%x, data: %" PRIdPTR " (# " +#else (void)printf("sig: kevent flags: 0x%x, data: %" PRId64 " (# " +#endif "times signal posted)\n", event[0].flags, event[0].data); } -- cgit v1.1 From d881b8eb8843bab6213c03d985c02dbbff945c39 Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 9 Feb 2017 21:19:24 +0000 Subject: MFC r279154,r279397: r279154 (by jilles): nice(): Correct return value and [EPERM] error. PR: 189821 Obtained from: NetBSD Relnotes: yes r279397 (by jilles): nice(): Put back old return value, keeping [EPERM] error. Commit r279154 changed the API and ABI significantly, and {NZERO} is still wrong. Also, preserve errno on success instead of setting it to 0. PR: 189821 Relnotes: yes --- contrib/netbsd-tests/lib/libc/gen/t_nice.c | 5 ----- lib/libc/gen/nice.3 | 36 ++++++++++++++++++++++++++---- lib/libc/gen/nice.c | 16 ++++++++----- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/contrib/netbsd-tests/lib/libc/gen/t_nice.c b/contrib/netbsd-tests/lib/libc/gen/t_nice.c index 10b8df7..7c6d232 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_nice.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_nice.c @@ -72,11 +72,6 @@ ATF_TC_BODY(nice_err, tc) { int i; -#ifdef __FreeBSD__ - atf_tc_expect_fail("nice(incr) with incr < 0 fails with unprivileged " - "users and sets errno == EPERM; see PR # 189821 for more details"); -#endif - /* * The call should fail with EPERM if the * supplied parameter is negative and the diff --git a/lib/libc/gen/nice.3 b/lib/libc/gen/nice.3 index 9c39b78..8ce13af 100644 --- a/lib/libc/gen/nice.3 +++ b/lib/libc/gen/nice.3 @@ -28,7 +28,7 @@ .\" @(#)nice.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd February 28, 2015 .Dt NICE 3 .Os .Sh NAME @@ -48,20 +48,48 @@ This interface is obsoleted by .Pp The .Fn nice -function obtains the scheduling priority of the process -from the system and sets it to the priority value specified in -.Fa incr . +function adds +.Fa incr +to the scheduling priority of the process. The priority is a value in the range -20 to 20. The default priority is 0; lower priorities cause more favorable scheduling. Only the super-user may lower priorities. .Pp Children inherit the priority of their parent processes via .Xr fork 2 . +.Sh RETURN VALUES +Upon successful completion, +.Fn nice +returns 0, and +.Va errno +is unchanged. +Otherwise, \-1 is returned, the process' nice value is not changed, and +.Va errno +is set to indicate the error. +.Sh ERRORS +The +.Fn nice +function will fail if: +.Bl -tag -width Er +.It Bq Er EPERM +The +.Fa incr +argument is negative and the caller does not have appropriate privileges. +.El .Sh SEE ALSO .Xr nice 1 , .Xr fork 2 , .Xr setpriority 2 , .Xr renice 8 +.Sh STANDARDS +The +.Fn nice +function conforms to +.St -p1003.1-2008 +except for the return value. +This implementation returns 0 upon successful completion but +the standard requires returning the new nice value, +which could be \-1. .Sh HISTORY A .Fn nice diff --git a/lib/libc/gen/nice.c b/lib/libc/gen/nice.c index e8375e8..ba9524b 100644 --- a/lib/libc/gen/nice.c +++ b/lib/libc/gen/nice.c @@ -43,14 +43,20 @@ __FBSDID("$FreeBSD$"); * Backwards compatible nice. */ int -nice(incr) - int incr; +nice(int incr) { - int prio; + int saverrno, prio; + saverrno = errno; errno = 0; prio = getpriority(PRIO_PROCESS, 0); - if (prio == -1 && errno) + if (prio == -1 && errno != 0) return (-1); - return (setpriority(PRIO_PROCESS, 0, prio + incr)); + if (setpriority(PRIO_PROCESS, 0, prio + incr) == -1) { + if (errno == EACCES) + errno = EPERM; + return (-1); + } + errno = saverrno; + return (0); } -- cgit v1.1 From a7022cbffe1ecbf64f5010813bbfad9220560101 Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 9 Feb 2017 21:23:41 +0000 Subject: MFC r283584: Relnotes: yes r283584 (by emaste): memmem(3): empty little string matches the beginning of the big string This function originated in glibc, and this matches their behaviour (and NetBSD, OpenBSD, and musl). An empty big string (arg "l") is handled by the existing l_len < s_len test. --- contrib/netbsd-tests/lib/libc/string/t_memmem.c | 2 +- lib/libc/string/memmem.3 | 22 ++++++++++++++-------- lib/libc/string/memmem.c | 6 +++--- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/contrib/netbsd-tests/lib/libc/string/t_memmem.c b/contrib/netbsd-tests/lib/libc/string/t_memmem.c index 8734bc3..5807662 100644 --- a/contrib/netbsd-tests/lib/libc/string/t_memmem.c +++ b/contrib/netbsd-tests/lib/libc/string/t_memmem.c @@ -75,7 +75,7 @@ ATF_TC_HEAD(memmem_basic, tc) ATF_TC_BODY(memmem_basic, tc) { -#if defined(__darwin__) || defined(__FreeBSD__) +#if defined(__darwin__) expect(memmem(b2, lb2, p0, lp0) == NULL); expect(memmem(b0, lb0, p0, lp0) == NULL); #else diff --git a/lib/libc/string/memmem.3 b/lib/libc/string/memmem.3 index 73c267c..fb341f4 100644 --- a/lib/libc/string/memmem.3 +++ b/lib/libc/string/memmem.3 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 24, 2005 +.Dd May 26, 2015 .Dt MEMMEM 3 .Os .Sh NAME @@ -51,14 +51,12 @@ in the byte string .Fa big . .Sh RETURN VALUES If -.Fa big_len -is smaller than -.Fa little_len , -if .Fa little_len -is 0, if -.Fa big_len -is 0 or if +is zero +.Fa big +is returned (that is, an empty little is deemed to match at the beginning of +big); +if .Fa little occurs nowhere in .Fa big , @@ -84,3 +82,11 @@ function first appeared in .Sh BUGS This function was broken in Linux libc up to and including version 5.0.9 and in GNU libc prior to version 2.1. +Prior to +.Fx 11.0 +.Nm +returned +.Dv NULL +when +.Fa little_len +equals 0. diff --git a/lib/libc/string/memmem.c b/lib/libc/string/memmem.c index 72e6517..3fd05df 100644 --- a/lib/libc/string/memmem.c +++ b/lib/libc/string/memmem.c @@ -42,9 +42,9 @@ memmem(const void *l, size_t l_len, const void *s, size_t s_len) const char *cl = (const char *)l; const char *cs = (const char *)s; - /* we need something to compare */ - if (l_len == 0 || s_len == 0) - return NULL; + /* empty "s" matches the beginning of "l" */ + if (s_len == 0) + return (void *)cl; /* "s" must be smaller or equal to "l" */ if (l_len < s_len) -- cgit v1.1 From fec4dffc3487939185515738cb54d7b0e89a1921 Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 9 Feb 2017 21:26:14 +0000 Subject: MFC r277648: r277648 (by jilles): Enable utimensat tests from NetBSD. As with other tests from c063, a required #include was missing. --- contrib/netbsd-tests/lib/libc/c063/t_utimensat.c | 3 +++ lib/libc/tests/c063/Makefile | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/netbsd-tests/lib/libc/c063/t_utimensat.c b/contrib/netbsd-tests/lib/libc/c063/t_utimensat.c index 9f21fd6..bbfa28b 100644 --- a/contrib/netbsd-tests/lib/libc/c063/t_utimensat.c +++ b/contrib/netbsd-tests/lib/libc/c063/t_utimensat.c @@ -40,6 +40,9 @@ __RCSID("$NetBSD: t_utimensat.c,v 1.5 2013/03/17 04:46:06 jmmv Exp $"); #include #include #include +#ifdef __FreeBSD__ +#include +#endif #include #define DIR "dir" diff --git a/lib/libc/tests/c063/Makefile b/lib/libc/tests/c063/Makefile index b81f575..27c44dc 100644 --- a/lib/libc/tests/c063/Makefile +++ b/lib/libc/tests/c063/Makefile @@ -2,7 +2,7 @@ TESTSDIR= ${TESTSBASE}/lib/libc/c063 -#TODO: t_o_search, t_utimensat +#TODO: t_o_search NETBSD_ATF_TESTS_C= faccessat_test NETBSD_ATF_TESTS_C+= fchmodat_test @@ -18,6 +18,7 @@ NETBSD_ATF_TESTS_C+= readlinkat_test NETBSD_ATF_TESTS_C+= renameat_test NETBSD_ATF_TESTS_C+= symlinkat_test NETBSD_ATF_TESTS_C+= unlinkat_test +NETBSD_ATF_TESTS_C+= utimensat CFLAGS+= -D_INCOMPLETE_XOPEN_C063 -- cgit v1.1 From 237637fa313dcd7c981f44ea35296cda3be981cb Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 9 Feb 2017 21:29:18 +0000 Subject: MFC r276527: Don't install h_raw if dealing with clang 3.5.0+ to unbreak the tests2 Jenkins job The h_raw application doesn't do proper bounds checking without the option being supplied via the build, which means that it doesn't throw signals and fail as expected PR: 196430 --- contrib/netbsd-tests/lib/libc/ssp/t_ssp.sh | 3 +++ lib/libc/tests/ssp/Makefile | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/ssp/t_ssp.sh b/contrib/netbsd-tests/lib/libc/ssp/t_ssp.sh index 2986ccf..e535e3e 100755 --- a/contrib/netbsd-tests/lib/libc/ssp/t_ssp.sh +++ b/contrib/netbsd-tests/lib/libc/ssp/t_ssp.sh @@ -361,6 +361,9 @@ raw_head() raw_body() { prog="$(atf_get_srcdir)/h_raw" + # Begin FreeBSD + [ -x $prog ] || atf_skip "$prog is missing; skipping testcase" + # End FreeBSD h_pass "$prog 9" # Begin FreeBSD diff --git a/lib/libc/tests/ssp/Makefile b/lib/libc/tests/ssp/Makefile index cf767ce..7bc8660 100644 --- a/lib/libc/tests/ssp/Makefile +++ b/lib/libc/tests/ssp/Makefile @@ -26,7 +26,11 @@ PROGS+= h_getcwd PROGS+= h_memcpy PROGS+= h_memmove PROGS+= h_memset +# This testcase doesn't run properly when not compiled with -fsantize=bounds +# with clang, which is currently contingent on a compiler_rt update +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 30500 PROGS+= h_raw +.endif PROGS+= h_read PROGS+= h_readlink PROGS+= h_snprintf -- cgit v1.1 From 3fdc68df60c69521e878b8de562f6cb6d1b4eb5d Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 9 Feb 2017 21:54:18 +0000 Subject: MFC r277912,r278738,r279418,r280835,r288416: r277912 (by markj): Include required headers in DTrace test programs. r278738 (by markj): Tweak the fds test program so that it actually compiles. Also use 0 instead of -1 for the bogus ioctl command so that dmesg doesn't get spammed with sign extension warnings when the test program runs. r279418 (by markj): Add infrastructure to integrate the DTrace test suite with Kyua. For each test category, we generate a script containing ATF test cases for the tests under that category. Each test case simply runs dtest.pl (the upstream test harness) with the corresponding test files. The exclude.sh script is used to record info about tests which should be skipped or are expected to fail; it is used to generate atf_skip and atf_expect_fail calls. The genmakefiles.sh script can be used to regenerate the test makefiles when new tests are brought it from upstream. The test suite is currently not connected to the build as there is a small number of lingering test issues which still need to be worked out. In the meantime however, the test suite can be easily built and installed manually from cddl/usr.sbin/dtrace/tests. r280835 (by markj): Replace dtest.pl, the upstream DTrace test suite harness, with a shell script. This reimplementation is much simpler than dtest.pl and is more amenable to being run under Kyua - dtest.pl writes error output to a temporary directory that is deleted when the run finishes, making it hard to debug test failures. This change also removes the test suite's dependency on perl. r288416 (by markj): Update DTrace test makefiles after r288415. --- .../cmd/dtrace/test/tst/common/io/tst.fds.c | 13 +- .../cmd/dtrace/test/tst/common/io/tst.fds.d | 2 +- .../cmd/dtrace/test/tst/common/json/tst.usdt.c | 2 + .../cmd/dtrace/test/tst/common/nfs/tst.call3.c | 1 + .../cmd/dtrace/test/tst/common/pid/tst.args1.c | 1 + .../cmd/dtrace/test/tst/common/pid/tst.gcc.c | 2 + .../cmd/dtrace/test/tst/common/pid/tst.ret1.c | 1 + .../cmd/dtrace/test/tst/common/pid/tst.ret2.c | 1 + .../cmd/dtrace/test/tst/common/pid/tst.weak1.c | 1 + .../cmd/dtrace/test/tst/common/pid/tst.weak2.c | 1 + .../cmd/dtrace/test/tst/common/syscall/tst.args.c | 1 + .../cmd/dtrace/test/tst/common/usdt/tst.forker.c | 4 + cddl/usr.sbin/dtrace/tests/Makefile | 15 ++ cddl/usr.sbin/dtrace/tests/Makefile.inc1 | 52 ++++++ cddl/usr.sbin/dtrace/tests/common/Makefile | 91 ++++++++++ cddl/usr.sbin/dtrace/tests/common/aggs/Makefile | 189 ++++++++++++++++++++ .../dtrace/tests/common/arithmetic/Makefile | 32 ++++ cddl/usr.sbin/dtrace/tests/common/arrays/Makefile | 29 +++ cddl/usr.sbin/dtrace/tests/common/assocs/Makefile | 32 ++++ cddl/usr.sbin/dtrace/tests/common/begin/Makefile | 22 +++ .../dtrace/tests/common/bitfields/Makefile | 26 +++ .../dtrace/tests/common/buffering/Makefile | 37 ++++ .../dtrace/tests/common/builtinvar/Makefile | 48 +++++ cddl/usr.sbin/dtrace/tests/common/cg/Makefile | 18 ++ cddl/usr.sbin/dtrace/tests/common/clauses/Makefile | 26 +++ cddl/usr.sbin/dtrace/tests/common/cpc/Makefile | 27 +++ cddl/usr.sbin/dtrace/tests/common/decls/Makefile | 30 ++++ .../dtrace/tests/common/docsExamples/Makefile | 32 ++++ cddl/usr.sbin/dtrace/tests/common/drops/Makefile | 24 +++ .../dtrace/tests/common/dtraceUtil/Makefile | 118 +++++++++++++ cddl/usr.sbin/dtrace/tests/common/end/Makefile | 21 +++ cddl/usr.sbin/dtrace/tests/common/enum/Makefile | 21 +++ cddl/usr.sbin/dtrace/tests/common/error/Makefile | 21 +++ cddl/usr.sbin/dtrace/tests/common/exit/Makefile | 19 ++ .../dtrace/tests/common/fbtprovider/Makefile | 26 +++ cddl/usr.sbin/dtrace/tests/common/funcs/Makefile | 113 ++++++++++++ cddl/usr.sbin/dtrace/tests/common/grammar/Makefile | 20 +++ cddl/usr.sbin/dtrace/tests/common/include/Makefile | 17 ++ cddl/usr.sbin/dtrace/tests/common/inline/Makefile | 28 +++ cddl/usr.sbin/dtrace/tests/common/io/Makefile | 18 ++ cddl/usr.sbin/dtrace/tests/common/ip/Makefile | 36 ++++ .../usr.sbin/dtrace/tests/common/java_api/Makefile | 44 +++++ cddl/usr.sbin/dtrace/tests/common/json/Makefile | 23 +++ cddl/usr.sbin/dtrace/tests/common/lexer/Makefile | 30 ++++ .../dtrace/tests/common/llquantize/Makefile | 50 ++++++ cddl/usr.sbin/dtrace/tests/common/mdb/Makefile | 17 ++ cddl/usr.sbin/dtrace/tests/common/mib/Makefile | 19 ++ cddl/usr.sbin/dtrace/tests/common/misc/Makefile | 30 ++++ .../dtrace/tests/common/multiaggs/Makefile | 34 ++++ cddl/usr.sbin/dtrace/tests/common/nfs/Makefile | 19 ++ .../usr.sbin/dtrace/tests/common/offsetof/Makefile | 28 +++ .../dtrace/tests/common/operators/Makefile | 18 ++ cddl/usr.sbin/dtrace/tests/common/pid/Makefile | 69 ++++++++ .../dtrace/tests/common/plockstat/Makefile | 19 ++ .../usr.sbin/dtrace/tests/common/pointers/Makefile | 48 +++++ cddl/usr.sbin/dtrace/tests/common/pragma/Makefile | 30 ++++ .../dtrace/tests/common/predicates/Makefile | 25 +++ .../dtrace/tests/common/preprocessor/Makefile | 53 ++++++ cddl/usr.sbin/dtrace/tests/common/print/Makefile | 32 ++++ cddl/usr.sbin/dtrace/tests/common/printa/Makefile | 40 +++++ cddl/usr.sbin/dtrace/tests/common/printf/Makefile | 68 ++++++++ cddl/usr.sbin/dtrace/tests/common/privs/Makefile | 24 +++ cddl/usr.sbin/dtrace/tests/common/probes/Makefile | 36 ++++ cddl/usr.sbin/dtrace/tests/common/proc/Makefile | 30 ++++ .../dtrace/tests/common/profile-n/Makefile | 53 ++++++ .../dtrace/tests/common/providers/Makefile | 44 +++++ cddl/usr.sbin/dtrace/tests/common/raise/Makefile | 21 +++ cddl/usr.sbin/dtrace/tests/common/rates/Makefile | 21 +++ cddl/usr.sbin/dtrace/tests/common/safety/Makefile | 54 ++++++ cddl/usr.sbin/dtrace/tests/common/scalars/Makefile | 37 ++++ cddl/usr.sbin/dtrace/tests/common/sched/Makefile | 19 ++ .../dtrace/tests/common/scripting/Makefile | 49 ++++++ cddl/usr.sbin/dtrace/tests/common/sdt/Makefile | 17 ++ cddl/usr.sbin/dtrace/tests/common/sizeof/Makefile | 31 ++++ .../dtrace/tests/common/speculation/Makefile | 75 ++++++++ .../dtrace/tests/common/stability/Makefile | 17 ++ cddl/usr.sbin/dtrace/tests/common/stack/Makefile | 22 +++ .../dtrace/tests/common/stackdepth/Makefile | 17 ++ cddl/usr.sbin/dtrace/tests/common/stop/Makefile | 19 ++ cddl/usr.sbin/dtrace/tests/common/strlen/Makefile | 17 ++ cddl/usr.sbin/dtrace/tests/common/strtoll/Makefile | 20 +++ cddl/usr.sbin/dtrace/tests/common/struct/Makefile | 31 ++++ cddl/usr.sbin/dtrace/tests/common/syscall/Makefile | 18 ++ .../usr.sbin/dtrace/tests/common/sysevent/Makefile | 19 ++ cddl/usr.sbin/dtrace/tests/common/tick-n/Makefile | 38 ++++ cddl/usr.sbin/dtrace/tests/common/trace/Makefile | 24 +++ .../usr.sbin/dtrace/tests/common/tracemem/Makefile | 26 +++ .../dtrace/tests/common/translators/Makefile | 51 ++++++ cddl/usr.sbin/dtrace/tests/common/typedef/Makefile | 21 +++ cddl/usr.sbin/dtrace/tests/common/types/Makefile | 69 ++++++++ cddl/usr.sbin/dtrace/tests/common/uctf/Makefile | 41 +++++ cddl/usr.sbin/dtrace/tests/common/union/Makefile | 27 +++ cddl/usr.sbin/dtrace/tests/common/usdt/Makefile | 65 +++++++ cddl/usr.sbin/dtrace/tests/common/ustack/Makefile | 20 +++ cddl/usr.sbin/dtrace/tests/common/vars/Makefile | 23 +++ cddl/usr.sbin/dtrace/tests/common/version/Makefile | 17 ++ cddl/usr.sbin/dtrace/tests/tools/dtest.sh | 129 ++++++++++++++ cddl/usr.sbin/dtrace/tests/tools/exclude.sh | 194 +++++++++++++++++++++ cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh | 85 +++++++++ cddl/usr.sbin/dtrace/tests/tools/gentest.sh | 110 ++++++++++++ etc/mtree/BSD.tests.dist | 162 +++++++++++++++++ 101 files changed, 3700 insertions(+), 7 deletions(-) create mode 100644 cddl/usr.sbin/dtrace/tests/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/Makefile.inc1 create mode 100644 cddl/usr.sbin/dtrace/tests/common/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/aggs/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/arithmetic/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/arrays/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/assocs/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/begin/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/bitfields/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/buffering/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/builtinvar/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/cg/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/clauses/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/cpc/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/decls/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/docsExamples/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/drops/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/dtraceUtil/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/end/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/enum/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/error/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/exit/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/funcs/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/grammar/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/include/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/inline/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/io/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/ip/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/java_api/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/json/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/lexer/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/mdb/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/mib/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/misc/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/multiaggs/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/nfs/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/offsetof/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/operators/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/pid/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/plockstat/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/pointers/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/pragma/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/predicates/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/preprocessor/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/print/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/printa/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/printf/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/privs/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/probes/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/proc/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/providers/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/raise/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/rates/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/safety/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/scalars/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/sched/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/scripting/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/sdt/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/sizeof/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/speculation/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/stability/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/stack/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/stackdepth/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/stop/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/strlen/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/strtoll/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/struct/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/syscall/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/sysevent/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/tick-n/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/trace/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/tracemem/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/translators/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/typedef/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/types/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/uctf/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/union/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/usdt/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/ustack/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/vars/Makefile create mode 100644 cddl/usr.sbin/dtrace/tests/common/version/Makefile create mode 100755 cddl/usr.sbin/dtrace/tests/tools/dtest.sh create mode 100755 cddl/usr.sbin/dtrace/tests/tools/exclude.sh create mode 100755 cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh create mode 100755 cddl/usr.sbin/dtrace/tests/tools/gentest.sh diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.c index 3cded11..9b878a2 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.c @@ -26,6 +26,8 @@ #pragma ident "%Z%%M% %I% %E% SMI" +#include + #include #include #include @@ -69,7 +71,7 @@ main(int argc, char *argv[]) */ if (sigsetjmp(env, 1) == 0) { for (;;) - (void) ioctl(-1, -1, NULL); + (void) ioctl(-1, 0, NULL); } /* @@ -80,20 +82,19 @@ main(int argc, char *argv[]) fds[n++] = open(file, O_WRONLY); fds[n++] = open(file, O_RDWR); - fds[n++] = open(file, O_RDWR | O_APPEND | O_CREAT | O_DSYNC | - O_LARGEFILE | O_NOCTTY | O_NONBLOCK | O_NDELAY | O_RSYNC | - O_SYNC | O_TRUNC | O_XATTR, 0666); + fds[n++] = open(file, O_RDWR | O_APPEND | O_CREAT | + O_NOCTTY | O_NONBLOCK | O_NDELAY | O_SYNC | O_TRUNC | 0666); fds[n++] = open(file, O_RDWR); (void) lseek(fds[n - 1], 123, SEEK_SET); /* * Once we have all the file descriptors in the state we want to test, - * issue a bogus ioctl() on each fd with cmd -1 and arg NULL to whack + * issue a bogus ioctl() on each fd with cmd 0 and arg NULL to whack * our DTrace script into recording the content of the fds[] array. */ for (i = 0; i < n; i++) - (void) ioctl(fds[i], -1, NULL); + (void) ioctl(fds[i], 0, NULL); assert(n <= sizeof (fds) / sizeof (fds[0])); exit(0); diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.d index 52a3312..8685142 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.d +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/io/tst.fds.d @@ -36,7 +36,7 @@ syscall::ioctl:entry } syscall::ioctl:entry -/pid == $1 && arg0 != -1u && arg1 == -1u && arg2 == NULL/ +/pid == $1 && arg0 != -1u && arg1 == 0 && arg2 == NULL/ { printf("fds[%d] fi_name = %s\n", arg0, fds[arg0].fi_name); printf("fds[%d] fi_dirname = %s\n", arg0, fds[arg0].fi_dirname); diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/json/tst.usdt.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/json/tst.usdt.c index 307106d..2a54d49 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/json/tst.usdt.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/json/tst.usdt.c @@ -14,6 +14,8 @@ */ #include +#include +#include #include "usdt.h" #define FMT "{" \ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/nfs/tst.call3.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/nfs/tst.call3.c index bd89fff..dda3ef2 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/nfs/tst.call3.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/nfs/tst.call3.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.args1.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.args1.c index 23bbab2..28d0677 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.args1.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.args1.c @@ -27,6 +27,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include +#include #include int diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.gcc.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.gcc.c index 69df472..b3959c3 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.gcc.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.gcc.c @@ -26,6 +26,8 @@ #pragma ident "%Z%%M% %I% %E% SMI" +#include +#include #include #include #include diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret1.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret1.c index cfb88a8..12b3f72 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret1.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret1.c @@ -27,6 +27,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include +#include #include /* diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret2.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret2.c index b64aa05..ea5394e 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret2.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.ret2.c @@ -27,6 +27,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include +#include #include /* diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak1.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak1.c index 1418f2a..765c285 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak1.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak1.c @@ -27,6 +27,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include +#include #include /* diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c index 8dabbe6..42d8cde 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c @@ -27,6 +27,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include +#include #include /* diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/syscall/tst.args.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/syscall/tst.args.c index 209160b..198d9db 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/syscall/tst.args.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/syscall/tst.args.c @@ -28,6 +28,7 @@ #include #include +#include /*ARGSUSED*/ int diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.forker.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.forker.c index ade7f83..e229c0c 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.forker.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.forker.c @@ -26,6 +26,10 @@ #pragma ident "%Z%%M% %I% %E% SMI" +#include +#include + +#include #include #include "forker.h" diff --git a/cddl/usr.sbin/dtrace/tests/Makefile b/cddl/usr.sbin/dtrace/tests/Makefile new file mode 100644 index 0000000..dfd2b54 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/Makefile @@ -0,0 +1,15 @@ +# $FreeBSD$ + +.include + +TESTSDIR= ${TESTSBASE}/cddl/usr.sbin/dtrace +TESTS_SUBDIRS+= common + +.PATH: ${.CURDIR:H:H:H:H}/tests +KYUAFILE= YES + +.PATH: ${.CURDIR}/tools +SCRIPTSDIR= ${TESTSDIR} +SCRIPTS= dtest.sh + +.include diff --git a/cddl/usr.sbin/dtrace/tests/Makefile.inc1 b/cddl/usr.sbin/dtrace/tests/Makefile.inc1 new file mode 100644 index 0000000..6958f78 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/Makefile.inc1 @@ -0,0 +1,52 @@ +# $FreeBSD$ + +TESTGROUP= ${.CURDIR:H:T}/${.CURDIR:T} +TESTSRC= ${.CURDIR:H:H:H:H:H}/contrib/opensolaris/cmd/dtrace/test/tst/${TESTGROUP} +TESTSDIR= ${TESTSBASE}/cddl/usr.sbin/dtrace/${TESTGROUP} + +.if !defined(_RECURSING_PROGS) +FILESGROUPS+= FILES ${TESTGROUP} ${TESTGROUP}EXE + +${TESTGROUP}= ${TESTFILES} +${TESTGROUP}EXE= ${TESTEXES} +${TESTGROUP}EXEMODE= 0555 + +${TESTGROUP}DIR= ${TESTSDIR} +${TESTGROUP}EXEDIR= ${TESTSDIR} + +TESTWRAPPER= t_dtrace_contrib +ATF_TESTS_SH+= ${TESTWRAPPER} +TEST_METADATA.t_dtrace_contrib+= required_files="/usr/local/bin/ksh" +TEST_METADATA.t_dtrace_contrib+= required_user="root" + +GENTEST?= ${.CURDIR:H:H}/tools/gentest.sh +EXCLUDE= ${.CURDIR:H:H}/tools/exclude.sh +${TESTWRAPPER}.sh: ${GENTEST} ${EXCLUDE} ${${TESTGROUP}} + sh ${GENTEST} -e ${EXCLUDE} ${TESTGROUP} ${${TESTGROUP}:S/ */ /} > ${.TARGET} + +CLEANFILES+= ${TESTWRAPPER}.sh +.endif # !defined(_RECURSING_PROGS) + +.PATH: ${TESTSRC} + +PROGS= ${CFILES:T:S/.c$/.exe/g} +.for prog in ${PROGS} +SRCS.${prog}+= ${prog:S/.exe$/.c/} +BINDIR.${prog}= ${TESTSDIR} +MAN.${prog}= + +.if exists(${prog:S/^tst.//:S/.exe$/.d/}) +SRCS.${prog}+= ${prog:S/^tst.//:S/.exe$/.d/} +.endif +.endfor + +# Some tests depend on the internals of their corresponding test programs, +# so make sure the optimizer doesn't interfere with them. +CFLAGS+= -O0 + +# Test programs shouldn't be stripped; else we generally can't use the PID +# provider. +DEBUG_FLAGS= -g +STRIP= + +.include diff --git a/cddl/usr.sbin/dtrace/tests/common/Makefile b/cddl/usr.sbin/dtrace/tests/common/Makefile new file mode 100644 index 0000000..02381c6 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/Makefile @@ -0,0 +1,91 @@ +# $FreeBSD$ + +# We exclude several subdirectories: nfs and sysevent do not compile on +# FreeBSD, and docsExamples doesn't seem amenable to automated testing. + +TESTSDIR= ${TESTSBASE}/cddl/usr.sbin/dtrace/common +TESTS_SUBDIRS+= aggs \ + arithmetic \ + arrays \ + assocs \ + begin \ + bitfields \ + buffering \ + builtinvar \ + cg \ + clauses \ + cpc \ + decls \ + drops \ + dtraceUtil \ + end \ + enum \ + error \ + exit \ + fbtprovider \ + funcs \ + grammar \ + include \ + inline \ + io \ + ip \ + java_api \ + json \ + lexer \ + llquantize \ + mdb \ + mib \ + misc \ + multiaggs \ + offsetof \ + operators \ + pid \ + plockstat \ + pointers \ + pragma \ + predicates \ + preprocessor \ + print \ + printa \ + printf \ + privs \ + probes \ + proc \ + profile-n \ + providers \ + raise \ + rates \ + safety \ + scalars \ + sched \ + scripting \ + sdt \ + sizeof \ + speculation \ + stability \ + stack \ + stackdepth \ + stop \ + strlen \ + strtoll \ + struct \ + syscall \ + tick-n \ + trace \ + tracemem \ + translators \ + typedef \ + types \ + uctf \ + union \ + usdt \ + ustack \ + vars \ + version \ + +.PATH: ${.CURDIR:H:H:H:H:H}/tests +KYUAFILE= YES + +SUBDIR_PARALLEL= + +.include diff --git a/cddl/usr.sbin/dtrace/tests/common/aggs/Makefile b/cddl/usr.sbin/dtrace/tests/common/aggs/Makefile new file mode 100644 index 0000000..d8a5ef0 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/aggs/Makefile @@ -0,0 +1,189 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_AGG_FUNC.bad.d \ + err.D_AGG_MDIM.bad.d \ + err.D_AGG_NULL.bad.d \ + err.D_AGG_REDEF.redef.d \ + err.D_AGG_SCALAR.avgtoofew.d \ + err.D_AGG_SCALAR.maxnoarg.d \ + err.D_AGG_SCALAR.mintoofew.d \ + err.D_AGG_SCALAR.quantizetoofew.d \ + err.D_AGG_SCALAR.stddevtoofew.d \ + err.D_AGG_SCALAR.sumtoofew.d \ + err.D_CLEAR_AGGARG.bad.d \ + err.D_CLEAR_PROTO.bad.d \ + err.D_FUNC_IDENT.bad.d \ + err.D_FUNC_UNDEF.badaggfunc.d \ + err.D_IDENT_UNDEF.badexpr.d \ + err.D_IDENT_UNDEF.badkey3.d \ + err.D_IDENT_UNDEF.noeffect.d \ + err.D_KEY_TYPE.badkey1.d \ + err.D_KEY_TYPE.badkey2.d \ + err.D_KEY_TYPE.badkey4.d \ + err.D_LQUANT_BASETYPE.lqbad1.d \ + err.D_LQUANT_BASETYPE.lqshort.d \ + err.D_LQUANT_BASEVAL.bad.d \ + err.D_LQUANT_LIMTYPE.lqbad1.d \ + err.D_LQUANT_LIMVAL.bad.d \ + err.D_LQUANT_MATCHBASE.d \ + err.D_LQUANT_MATCHBASE.order.d \ + err.D_LQUANT_MATCHLIM.d \ + err.D_LQUANT_MATCHLIM.order.d \ + err.D_LQUANT_MATCHSTEP.d \ + err.D_LQUANT_MISMATCH.lqbadarg.d \ + err.D_LQUANT_STEPLARGE.lqtoofew.d \ + err.D_LQUANT_STEPSMALL.bad.d \ + err.D_LQUANT_STEPTYPE.lqbadinc.d \ + err.D_LQUANT_STEPVAL.bad.d \ + err.D_NORMALIZE_AGGARG.bad.d \ + err.D_NORMALIZE_PROTO.bad.d \ + err.D_NORMALIZE_SCALAR.bad.d \ + err.D_PROTO_ARG.lquantizetoofew.d \ + err.D_PROTO_LEN.avgnoarg.d \ + err.D_PROTO_LEN.avgtoomany.d \ + err.D_PROTO_LEN.counttoomany.d \ + err.D_PROTO_LEN.lquantizenoarg.d \ + err.D_PROTO_LEN.lquantizetoomany.d \ + err.D_PROTO_LEN.maxnoarg.d \ + err.D_PROTO_LEN.maxtoomany.d \ + err.D_PROTO_LEN.minnoarg.d \ + err.D_PROTO_LEN.mintoomany.d \ + err.D_PROTO_LEN.quantizenoarg.d \ + err.D_PROTO_LEN.quantizetoomany.d \ + err.D_PROTO_LEN.stddevnoarg.d \ + err.D_PROTO_LEN.stddevtoomany.d \ + err.D_PROTO_LEN.sumnoarg.d \ + err.D_PROTO_LEN.sumtoomany.d \ + err.D_TRUNC_AGGARG.bad.d \ + err.D_TRUNC_PROTO.badmany.d \ + err.D_TRUNC_PROTO.badnone.d \ + err.D_TRUNC_SCALAR.bad.d \ + tst.aggencoding.d \ + tst.aggencoding.d.out \ + tst.agghist.d \ + tst.agghist.d.out \ + tst.aggpack.d \ + tst.aggpack.d.out \ + tst.aggpackbanner.ksh \ + tst.aggpackbanner.ksh.out \ + tst.aggpackzoom.d \ + tst.aggpackzoom.d.out \ + tst.aggzoom.d \ + tst.aggzoom.d.out \ + tst.allquant.d \ + tst.allquant.d.out \ + tst.avg.d \ + tst.avg.d.out \ + tst.avg_neg.d \ + tst.avg_neg.d.out \ + tst.clear.d \ + tst.clear.d.out \ + tst.clearavg.d \ + tst.clearavg.d.out \ + tst.clearavg2.d \ + tst.clearavg2.d.out \ + tst.cleardenormalize.d \ + tst.cleardenormalize.d.out \ + tst.clearlquantize.d \ + tst.clearlquantize.d.out \ + tst.clearnormalize.d \ + tst.clearnormalize.d.out \ + tst.clearstddev.d \ + tst.clearstddev.d.out \ + tst.count.d \ + tst.count.d.out \ + tst.count2.d \ + tst.count2.d.out \ + tst.count3.d \ + tst.denormalize.d \ + tst.denormalize.d.out \ + tst.denormalizeonly.d \ + tst.denormalizeonly.d.out \ + tst.fmtnormalize.d \ + tst.fmtnormalize.d.out \ + tst.forms.d \ + tst.forms.d.out \ + tst.goodkey.d \ + tst.keysort.d \ + tst.keysort.d.out \ + tst.lquantize.d \ + tst.lquantize.d.out \ + tst.lquantnormal.d \ + tst.lquantnormal.d.out \ + tst.lquantrange.d \ + tst.lquantrange.d.out \ + tst.lquantround.d \ + tst.lquantround.d.out \ + tst.lquantzero.d \ + tst.lquantzero.d.out \ + tst.max.d \ + tst.max.d.out \ + tst.max_neg.d \ + tst.max_neg.d.out \ + tst.min.d \ + tst.min.d.out \ + tst.min_neg.d \ + tst.min_neg.d.out \ + tst.multiaggs1.d \ + tst.multiaggs2.d \ + tst.multiaggs2.d.out \ + tst.multiaggs3.d \ + tst.multiaggs3.d.out \ + tst.multinormalize.d \ + tst.multinormalize.d.out \ + tst.neglquant.d \ + tst.neglquant.d.out \ + tst.negorder.d \ + tst.negorder.d.out \ + tst.negquant.d \ + tst.negquant.d.out \ + tst.negtrunc.d \ + tst.negtrunc.d.out \ + tst.negtruncquant.d \ + tst.negtruncquant.d.out \ + tst.normalize.d \ + tst.normalize.d.out \ + tst.order.d \ + tst.order.d.out \ + tst.quantize.d \ + tst.quantize.d.out \ + tst.quantmany.d \ + tst.quantmany.d.out \ + tst.quantround.d \ + tst.quantround.d.out \ + tst.quantzero.d \ + tst.quantzero.d.out \ + tst.signature.d \ + tst.signedkeys.d \ + tst.signedkeys.d.out \ + tst.signedkeyspos.d \ + tst.signedkeyspos.d.out \ + tst.sizedkeys.d \ + tst.sizedkeys.d.out \ + tst.stddev.d \ + tst.stddev.d.out \ + tst.subr.d \ + tst.sum.d \ + tst.sum.d.out \ + tst.trunc.d \ + tst.trunc.d.out \ + tst.trunc0.d \ + tst.trunc0.d.out \ + tst.truncquant.d \ + tst.truncquant.d.out \ + tst.valsortkeypos.d \ + tst.valsortkeypos.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/arithmetic/Makefile b/cddl/usr.sbin/dtrace/tests/common/arithmetic/Makefile new file mode 100644 index 0000000..7f1fa96 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/arithmetic/Makefile @@ -0,0 +1,32 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_DIV_ZERO.divby0.d \ + err.D_DIV_ZERO.divby0_1.d \ + err.D_DIV_ZERO.divby0_2.d \ + err.D_DIV_ZERO.modby0.d \ + err.D_SYNTAX.addmin.d \ + err.D_SYNTAX.divmin.d \ + err.D_SYNTAX.muladd.d \ + err.D_SYNTAX.muldiv.d \ + tst.basics.d \ + tst.basics.d.out \ + tst.compcast.d \ + tst.compcast.d.out \ + tst.compnarrowassign.d \ + tst.compnarrowassign.d.out \ + tst.execcast.d \ + tst.execcast.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/arrays/Makefile b/cddl/usr.sbin/dtrace/tests/common/arrays/Makefile new file mode 100644 index 0000000..608388f --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/arrays/Makefile @@ -0,0 +1,29 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_ARR_BADREF.bad.d \ + err.D_DECL_ARRBIG.toobig.d \ + err.D_DECL_ARRNULL.bad.d \ + err.D_DECL_ARRSUB.bad.d \ + err.D_DECL_PROTO_TYPE.badtuple.d \ + err.D_IDENT_UNDEF.badureg.d \ + tst.basic1.d \ + tst.basic2.d \ + tst.basic3.d \ + tst.basic4.d \ + tst.basic5.d \ + tst.basic6.d \ + tst.uregsarray.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/assocs/Makefile b/cddl/usr.sbin/dtrace/tests/common/assocs/Makefile new file mode 100644 index 0000000..5d20b61 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/assocs/Makefile @@ -0,0 +1,32 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_OP_INCOMPAT.dupgtype.d \ + err.D_OP_INCOMPAT.dupttype.d \ + err.D_OP_INCOMPAT.this.d \ + err.D_PROTO_ARG.badsig.d \ + err.D_PROTO_LEN.toofew.d \ + err.D_PROTO_LEN.toomany.d \ + err.D_SYNTAX.errassign.d \ + err.tupoflow.d \ + tst.cpyarray.d \ + tst.diffprofile.d \ + tst.initialize.d \ + tst.invalidref.d \ + tst.misc.d \ + tst.orthogonality.d \ + tst.this.d \ + tst.valassign.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/begin/Makefile b/cddl/usr.sbin/dtrace/tests/common/begin/Makefile new file mode 100644 index 0000000..4437db9 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/begin/Makefile @@ -0,0 +1,22 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PDESC_ZERO.begin.d \ + err.D_PDESC_ZERO.tick.d \ + tst.begin.d \ + tst.begin.d.out \ + tst.multibegin.d \ + tst.multibegin.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/bitfields/Makefile b/cddl/usr.sbin/dtrace/tests/common/bitfields/Makefile new file mode 100644 index 0000000..838ad68 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/bitfields/Makefile @@ -0,0 +1,26 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_ADDROF_BITFIELD.BitfieldAddress.d \ + err.D_DECL_BFCONST.NegBitField.d \ + err.D_DECL_BFCONST.ZeroBitField.d \ + err.D_DECL_BFSIZE.ExceedBaseType.d \ + err.D_DECL_BFSIZE.GreaterThan64.d \ + err.D_DECL_BFTYPE.badtype.d \ + err.D_OFFSETOF_BITFIELD.d \ + err.D_SIZEOF_BITFIELD.SizeofBitfield.d \ + tst.BitFieldPromotion.d \ + tst.SizeofBitField.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/buffering/Makefile b/cddl/usr.sbin/dtrace/tests/common/buffering/Makefile new file mode 100644 index 0000000..7fe869b --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/buffering/Makefile @@ -0,0 +1,37 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.end.d \ + err.resize1.d \ + err.resize2.d \ + err.resize3.d \ + err.zerobuf.d \ + tst.alignring.d \ + tst.cputime.ksh \ + tst.dynvarsize.d \ + tst.fill1.d \ + tst.fill1.d.out \ + tst.resize1.d \ + tst.resize2.d \ + tst.resize3.d \ + tst.ring1.d \ + tst.ring2.d \ + tst.ring2.d.out \ + tst.ring3.d \ + tst.ring3.d.out \ + tst.smallring.d \ + tst.switch1.d \ + tst.switch1.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/builtinvar/Makefile b/cddl/usr.sbin/dtrace/tests/common/builtinvar/Makefile new file mode 100644 index 0000000..b955be5 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/builtinvar/Makefile @@ -0,0 +1,48 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_XLATE_NOCONV.cpuusage.d \ + err.D_XLATE_NOCONV.nice.d \ + err.D_XLATE_NOCONV.priority.d \ + err.D_XLATE_NOCONV.prsize.d \ + err.D_XLATE_NOCONV.rssize.d \ + tst.arg0.d \ + tst.arg0clause.d \ + tst.arg1.d \ + tst.arg1to8.d \ + tst.arg1to8clause.d \ + tst.caller.d \ + tst.caller1.d \ + tst.epid.d \ + tst.epid1.d \ + tst.errno.d \ + tst.errno1.d \ + tst.execname.d \ + tst.hpriority.d \ + tst.id.d \ + tst.id1.d \ + tst.ipl.d \ + tst.ipl1.d \ + tst.lwpsinfo.d \ + tst.lwpsinfo1.d \ + tst.pid.d \ + tst.pid1.d \ + tst.psinfo.d \ + tst.psinfo1.d \ + tst.tid.d \ + tst.tid1.d \ + tst.timestamp.d \ + tst.vtimestamp.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/cg/Makefile b/cddl/usr.sbin/dtrace/tests/common/cg/Makefile new file mode 100644 index 0000000..5550a8e --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/cg/Makefile @@ -0,0 +1,18 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_NOREG.noreg.d \ + err.baddif.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/clauses/Makefile b/cddl/usr.sbin/dtrace/tests/common/clauses/Makefile new file mode 100644 index 0000000..5d582f3 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/clauses/Makefile @@ -0,0 +1,26 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_IDENT_UNDEF.aggfun.d \ + err.D_IDENT_UNDEF.aggtup.d \ + err.D_IDENT_UNDEF.arrtup.d \ + err.D_IDENT_UNDEF.body.d \ + err.D_IDENT_UNDEF.both.d \ + err.D_IDENT_UNDEF.pred.d \ + tst.nopred.d \ + tst.pred.d \ + tst.predfirst.d \ + tst.predlast.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/cpc/Makefile b/cddl/usr.sbin/dtrace/tests/common/cpc/Makefile new file mode 100644 index 0000000..ad23c5a1 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/cpc/Makefile @@ -0,0 +1,27 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PDESC_ZERO.lowfrequency.d \ + err.D_PDESC_ZERO.malformedoverflow.d \ + err.D_PDESC_ZERO.nonexistentevent.d \ + err.cpcvscpustatpart1.ksh \ + err.cpcvscpustatpart2.ksh \ + err.cputrackfailtostart.ksh \ + err.cputrackterminates.ksh \ + err.toomanyenablings.d \ + tst.allcpus.ksh \ + tst.genericevent.d \ + tst.platformevent.ksh \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/decls/Makefile b/cddl/usr.sbin/dtrace/tests/common/decls/Makefile new file mode 100644 index 0000000..21544d9 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/decls/Makefile @@ -0,0 +1,30 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_DECL_LOCASSC.NonLocalAssoc.d \ + err.D_DECL_LONGINT.LongStruct.d \ + err.D_DECL_PARMCLASS.BadStorageClass.d \ + err.D_DECL_PROTO_NAME.VoidName.d \ + err.D_DECL_PROTO_TYPE.Dyn.d \ + err.D_DECL_PROTO_VARARGS.VarLenArgs.d \ + err.D_DECL_PROTO_VOID.NonSoleVoid.d \ + err.D_DECL_SIGNINT.UnsignedStruct.d \ + err.D_DECL_VOIDATTR.ShortVoidDecl.d \ + tst.arrays.d \ + tst.basics.d \ + tst.funcs.d \ + tst.pointers.d \ + tst.varargsfuncs.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/docsExamples/Makefile b/cddl/usr.sbin/dtrace/tests/common/docsExamples/Makefile new file mode 100644 index 0000000..6212862 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/docsExamples/Makefile @@ -0,0 +1,32 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + badptr.d \ + countdown.d \ + counter.d \ + errorpath.d \ + hello.d \ + kstat.d \ + ksyms.d \ + renormalize.d \ + rtime.d \ + rw.d \ + rwinfo.d \ + rwtime.d \ + specopen.d \ + truss.d \ + trussrw.d \ + userfunc.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/drops/Makefile b/cddl/usr.sbin/dtrace/tests/common/drops/Makefile new file mode 100644 index 0000000..248c201 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/drops/Makefile @@ -0,0 +1,24 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + drp.DTRACEDROP_AGGREGATION.d \ + drp.DTRACEDROP_DBLERROR.d \ + drp.DTRACEDROP_DYNAMIC.d \ + drp.DTRACEDROP_PRINCIPAL.d \ + drp.DTRACEDROP_PRINCIPAL.end.d \ + drp.DTRACEDROP_SPEC.d \ + drp.DTRACEDROP_SPECUNAVAIL.d \ + drp.DTRACEDROP_STKSTROVERFLOW.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/dtraceUtil/Makefile b/cddl/usr.sbin/dtrace/tests/common/dtraceUtil/Makefile new file mode 100644 index 0000000..60e6599 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/dtraceUtil/Makefile @@ -0,0 +1,118 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PDESC_ZERO.InvalidDescription1.d \ + man.APIVersion.d \ + man.AddSearchPath.d \ + man.CoalesceTrace.d \ + man.ELFGeneration.d \ + man.IncludedFilePath.d \ + man.ShowCompilerCode.d \ + man.VerboseStabilityReport.d \ + tst.AddSearchPath.d.ksh \ + tst.BufsizeGiga.d.ksh \ + tst.BufsizeKilo.d.ksh \ + tst.BufsizeMega.d.ksh \ + tst.BufsizeTera.d.ksh \ + tst.DataModel32.d.ksh \ + tst.DataModel64.d.ksh \ + tst.DefineNameWithCPP.d.ksh \ + tst.DefineNameWithCPP.d.ksh.out \ + tst.DestructWithFunction.d.ksh \ + tst.DestructWithFunction.d.ksh.out \ + tst.DestructWithID.d.ksh \ + tst.DestructWithID.d.ksh.out \ + tst.DestructWithModule.d.ksh \ + tst.DestructWithModule.d.ksh.out \ + tst.DestructWithName.d.ksh \ + tst.DestructWithName.d.ksh.out \ + tst.DestructWithProvider.d.ksh \ + tst.DestructWithProvider.d.ksh.out \ + tst.DestructWithoutW.d.ksh \ + tst.ELFGenerationOut.d.ksh \ + tst.ELFGenerationWithO.d.ksh \ + tst.ExitStatus1.d.ksh \ + tst.ExitStatus2.d.ksh \ + tst.ExtraneousProbeIds.d.ksh \ + tst.InvalidFuncName1.d.ksh \ + tst.InvalidFuncName2.d.ksh \ + tst.InvalidId1.d.ksh \ + tst.InvalidId2.d.ksh \ + tst.InvalidId3.d.ksh \ + tst.InvalidModule1.d.ksh \ + tst.InvalidModule2.d.ksh \ + tst.InvalidModule3.d.ksh \ + tst.InvalidModule4.d.ksh \ + tst.InvalidProbeIdentifier.d.ksh \ + tst.InvalidProvider1.d.ksh \ + tst.InvalidProvider2.d.ksh \ + tst.InvalidProvider3.d.ksh \ + tst.InvalidProvider4.d.ksh \ + tst.InvalidTraceFunc1.d.ksh \ + tst.InvalidTraceFunc2.d.ksh \ + tst.InvalidTraceFunc3.d.ksh \ + tst.InvalidTraceFunc4.d.ksh \ + tst.InvalidTraceFunc5.d.ksh \ + tst.InvalidTraceFunc6.d.ksh \ + tst.InvalidTraceFunc7.d.ksh \ + tst.InvalidTraceFunc8.d.ksh \ + tst.InvalidTraceFunc9.d.ksh \ + tst.InvalidTraceID1.d.ksh \ + tst.InvalidTraceID2.d.ksh \ + tst.InvalidTraceID3.d.ksh \ + tst.InvalidTraceID4.d.ksh \ + tst.InvalidTraceID5.d.ksh \ + tst.InvalidTraceID6.d.ksh \ + tst.InvalidTraceID7.d.ksh \ + tst.InvalidTraceModule1.d.ksh \ + tst.InvalidTraceModule2.d.ksh \ + tst.InvalidTraceModule3.d.ksh \ + tst.InvalidTraceModule4.d.ksh \ + tst.InvalidTraceModule5.d.ksh \ + tst.InvalidTraceModule6.d.ksh \ + tst.InvalidTraceModule7.d.ksh \ + tst.InvalidTraceModule8.d.ksh \ + tst.InvalidTraceName1.d.ksh \ + tst.InvalidTraceName2.d.ksh \ + tst.InvalidTraceName3.d.ksh \ + tst.InvalidTraceName4.d.ksh \ + tst.InvalidTraceName5.d.ksh \ + tst.InvalidTraceName6.d.ksh \ + tst.InvalidTraceName7.d.ksh \ + tst.InvalidTraceName8.d.ksh \ + tst.InvalidTraceName9.d.ksh \ + tst.InvalidTraceProvider1.d.ksh \ + tst.InvalidTraceProvider2.d.ksh \ + tst.InvalidTraceProvider3.d.ksh \ + tst.InvalidTraceProvider4.d.ksh \ + tst.InvalidTraceProvider5.d.ksh \ + tst.MultipleInvalidProbeId.d.ksh \ + tst.PreprocessorStatement.d.ksh \ + tst.QuietMode.d.ksh \ + tst.QuietMode.d.ksh.out \ + tst.TestCompile.d.ksh \ + tst.TestCompile.d.ksh.out \ + tst.UnDefineNameWithCPP.d.ksh \ + tst.ZeroFunctionProbes.d.ksh \ + tst.ZeroFunctionProbes.d.ksh.out \ + tst.ZeroModuleProbes.d.ksh \ + tst.ZeroModuleProbes.d.ksh.out \ + tst.ZeroNameProbes.d.ksh \ + tst.ZeroNameProbes.d.ksh.out \ + tst.ZeroProbeIdentfier.d.ksh \ + tst.ZeroProbesWithoutZ.d.ksh \ + tst.ZeroProviderProbes.d.ksh \ + tst.ZeroProviderProbes.d.ksh.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/end/Makefile b/cddl/usr.sbin/dtrace/tests/common/end/Makefile new file mode 100644 index 0000000..120a0dd --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/end/Makefile @@ -0,0 +1,21 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_IDENT_UNDEF.timespent.d \ + tst.end.d \ + tst.endwithoutbegin.d \ + tst.multibeginend.d \ + tst.multiend.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/enum/Makefile b/cddl/usr.sbin/dtrace/tests/common/enum/Makefile new file mode 100644 index 0000000..ee6ab1a --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/enum/Makefile @@ -0,0 +1,21 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_DECL_IDRED.EnumSameName.d \ + err.D_UNKNOWN.RepeatIdentifiers.d \ + tst.EnumEquality.d \ + tst.EnumSameValue.d \ + tst.EnumValAssign.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/error/Makefile b/cddl/usr.sbin/dtrace/tests/common/error/Makefile new file mode 100644 index 0000000..999e28c --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/error/Makefile @@ -0,0 +1,21 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.DTRACEFLT_BADADDR.d \ + tst.DTRACEFLT_DIVZERO.d \ + tst.DTRACEFLT_UNKNOWN.d \ + tst.error.d \ + tst.errorend.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/exit/Makefile b/cddl/usr.sbin/dtrace/tests/common/exit/Makefile new file mode 100644 index 0000000..d5aa843 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/exit/Makefile @@ -0,0 +1,19 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PROTO_LEN.noarg.d \ + err.exitarg1.d \ + tst.basic1.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile b/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile new file mode 100644 index 0000000..a84c38d --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile @@ -0,0 +1,26 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PDESC_ZERO.notreturn.d \ + tst.basic.d \ + tst.functionentry.d \ + tst.functionreturnvalue.d \ + tst.ioctlargs.d \ + tst.offset.d \ + tst.offsetzero.d \ + tst.return.d \ + tst.return0.d \ + tst.tailcall.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/funcs/Makefile b/cddl/usr.sbin/dtrace/tests/common/funcs/Makefile new file mode 100644 index 0000000..4a76912 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/funcs/Makefile @@ -0,0 +1,113 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_FUNC_UNDEF.progenyofbad1.d \ + err.D_OP_VFPTR.badop.d \ + err.D_PROTO_ARG.chillbadarg.d \ + err.D_PROTO_ARG.copyoutbadarg.d \ + err.D_PROTO_ARG.mobadarg.d \ + err.D_PROTO_ARG.raisebadarg.d \ + err.D_PROTO_ARG.tolower.d \ + err.D_PROTO_ARG.toupper.d \ + err.D_PROTO_LEN.allocanoarg.d \ + err.D_PROTO_LEN.badbreakpoint.d \ + err.D_PROTO_LEN.chilltoofew.d \ + err.D_PROTO_LEN.chilltoomany.d \ + err.D_PROTO_LEN.copyoutstrbadarg.d \ + err.D_PROTO_LEN.copyoutstrtoofew.d \ + err.D_PROTO_LEN.copyouttoofew.d \ + err.D_PROTO_LEN.copyouttoomany.d \ + err.D_PROTO_LEN.motoofew.d \ + err.D_PROTO_LEN.motoomany.d \ + err.D_PROTO_LEN.mtabadarg.d \ + err.D_PROTO_LEN.mtatoofew.d \ + err.D_PROTO_LEN.mtatoomany.d \ + err.D_PROTO_LEN.panicbadarg.d \ + err.D_PROTO_LEN.progenyofbad2.d \ + err.D_PROTO_LEN.stopbadarg.d \ + err.D_PROTO_LEN.tolower.d \ + err.D_PROTO_LEN.tolowertoomany.d \ + err.D_PROTO_LEN.toupper.d \ + err.D_PROTO_LEN.touppertoomany.d \ + err.D_STRINGOF_TYPE.badstringof.d \ + err.D_VAR_UNDEF.badvar.d \ + err.badalloca.d \ + err.badalloca2.d \ + err.badbcopy.d \ + err.badbcopy1.d \ + err.badbcopy2.d \ + err.badbcopy3.d \ + err.badbcopy4.d \ + err.badbcopy5.d \ + err.badbcopy6.d \ + err.badchill.d \ + err.chillbadarg.ksh \ + err.copyout.d \ + err.copyoutbadaddr.ksh \ + err.copyoutstrbadaddr.ksh \ + err.inet_ntoa6badaddr.d \ + err.inet_ntoabadaddr.d \ + err.inet_ntopbadaddr.d \ + err.inet_ntopbadarg.d \ + tst.badfreopen.ksh \ + tst.basename.d \ + tst.basename.d.out \ + tst.bcopy.d \ + tst.chill.ksh \ + tst.cleanpath.d \ + tst.cleanpath.d.out \ + tst.copyin.d \ + tst.copyinto.d \ + tst.ddi_pathname.d \ + tst.default.d \ + tst.freopen.ksh \ + tst.ftruncate.ksh \ + tst.ftruncate.ksh.out \ + tst.hton.d \ + tst.index.d \ + tst.index.d.out \ + tst.inet_ntoa.d \ + tst.inet_ntoa.d.out \ + tst.inet_ntoa6.d \ + tst.inet_ntoa6.d.out \ + tst.inet_ntop.d \ + tst.inet_ntop.d.out \ + tst.lltostr.d \ + tst.lltostr.d.out \ + tst.lltostrbase.d \ + tst.lltostrbase.d.out \ + tst.mutex_owned.d \ + tst.mutex_owner.d \ + tst.mutex_type_adaptive.d \ + tst.progenyof.d \ + tst.rand.d \ + tst.strchr.d \ + tst.strchr.d.out \ + tst.strjoin.d \ + tst.strjoin.d.out \ + tst.strstr.d \ + tst.strstr.d.out \ + tst.strtok.d \ + tst.strtok.d.out \ + tst.strtok_null.d \ + tst.substr.d \ + tst.substr.d.out \ + tst.substrminate.d \ + tst.substrminate.d.out \ + tst.system.d \ + tst.system.d.out \ + tst.tolower.d \ + tst.toupper.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/grammar/Makefile b/cddl/usr.sbin/dtrace/tests/common/grammar/Makefile new file mode 100644 index 0000000..e1854ae --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/grammar/Makefile @@ -0,0 +1,20 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_ADDROF_LVAL.d \ + err.D_EMPTY.empty.d \ + tst.clauses.d \ + tst.stmts.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/include/Makefile b/cddl/usr.sbin/dtrace/tests/common/include/Makefile new file mode 100644 index 0000000..b5002e9 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/include/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.includefirst.ksh \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/inline/Makefile b/cddl/usr.sbin/dtrace/tests/common/inline/Makefile new file mode 100644 index 0000000..7f848fd --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/inline/Makefile @@ -0,0 +1,28 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_DECL_IDRED.redef1.d \ + err.D_DECL_IDRED.redef2.d \ + err.D_IDENT_UNDEF.recur.d \ + err.D_OP_INCOMPAT.baddef1.d \ + err.D_OP_INCOMPAT.baddef2.d \ + err.D_OP_INCOMPAT.badxlate.d \ + tst.InlineDataAssign.d \ + tst.InlineExpression.d \ + tst.InlineKinds.d \ + tst.InlineKinds.d.out \ + tst.InlineTypedef.d \ + tst.InlineWritableAssign.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/io/Makefile b/cddl/usr.sbin/dtrace/tests/common/io/Makefile new file mode 100644 index 0000000..ad62351 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/io/Makefile @@ -0,0 +1,18 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.fds.d \ + tst.fds.d.out \ + +TESTEXES= \ + + +CFILES= \ + tst.fds.c \ + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/ip/Makefile b/cddl/usr.sbin/dtrace/tests/common/ip/Makefile new file mode 100644 index 0000000..369068a --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/ip/Makefile @@ -0,0 +1,36 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.ipv4localicmp.ksh \ + tst.ipv4localicmp.ksh.out \ + tst.ipv4localtcp.ksh \ + tst.ipv4localtcp.ksh.out \ + tst.ipv4localudp.ksh \ + tst.ipv4localudp.ksh.out \ + tst.ipv4remoteicmp.ksh \ + tst.ipv4remoteicmp.ksh.out \ + tst.ipv4remotetcp.ksh \ + tst.ipv4remotetcp.ksh.out \ + tst.ipv4remoteudp.ksh \ + tst.ipv4remoteudp.ksh.out \ + tst.ipv6localicmp.ksh \ + tst.ipv6localicmp.ksh.out \ + tst.ipv6remoteicmp.ksh \ + tst.ipv6remoteicmp.ksh.out \ + tst.localtcpstate.ksh \ + tst.localtcpstate.ksh.out \ + tst.remotetcpstate.ksh \ + tst.remotetcpstate.ksh.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/java_api/Makefile b/cddl/usr.sbin/dtrace/tests/common/java_api/Makefile new file mode 100644 index 0000000..4ef225a --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/java_api/Makefile @@ -0,0 +1,44 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.Abort.ksh \ + tst.Abort.ksh.out \ + tst.Bean.ksh \ + tst.Bean.ksh.out \ + tst.Close.ksh \ + tst.Close.ksh.out \ + tst.Drop.ksh \ + tst.Drop.ksh.out \ + tst.Enable.ksh \ + tst.Enable.ksh.out \ + tst.FunctionLookup.ksh \ + tst.FunctionLookup.ksh.out \ + tst.GetAggregate.ksh \ + tst.MaxConsumers.ksh \ + tst.MaxConsumers.ksh.out \ + tst.MultiAggPrinta.ksh \ + tst.MultiAggPrinta.ksh.out \ + tst.ProbeData.ksh \ + tst.ProbeData.ksh.out \ + tst.ProbeDescription.ksh \ + tst.ProbeDescription.ksh.out \ + tst.StateMachine.ksh \ + tst.StateMachine.ksh.out \ + tst.StopLock.ksh \ + tst.StopLock.ksh.out \ + tst.printa.d \ + tst.printa.d.out \ + +TESTEXES= \ + + +CFILES= \ + tst.FunctionLookup.c \ + tst.ProbeData.c \ + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/json/Makefile b/cddl/usr.sbin/dtrace/tests/common/json/Makefile new file mode 100644 index 0000000..160fcae --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/json/Makefile @@ -0,0 +1,23 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.general.d \ + tst.general.d.out \ + tst.strsize.d \ + tst.strsize.d.out \ + tst.usdt.d \ + tst.usdt.d.out \ + usdt.d \ + +TESTEXES= \ + + +CFILES= \ + tst.usdt.c \ + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/lexer/Makefile b/cddl/usr.sbin/dtrace/tests/common/lexer/Makefile new file mode 100644 index 0000000..39063e4 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/lexer/Makefile @@ -0,0 +1,30 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_CHR_NL.char.d \ + err.D_CHR_NULL.char.d \ + err.D_INT_DIGIT.InvalidDigit.d \ + err.D_INT_OFLOW.BigInt.d \ + err.D_STR_NL.string.d \ + err.D_SYNTAX.brace1.d \ + err.D_SYNTAX.brace2.d \ + err.D_SYNTAX.brack1.d \ + err.D_SYNTAX.brack2.d \ + err.D_SYNTAX.brack3.d \ + err.D_SYNTAX.paren1.d \ + err.D_SYNTAX.paren2.d \ + err.D_SYNTAX.paren3.d \ + tst.D_MACRO_OFLOW.ParIntOvflow.d.ksh \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile b/cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile new file mode 100644 index 0000000..1f33e8a --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile @@ -0,0 +1,50 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_LLQUANT_FACTOREVEN.nodivide.d \ + err.D_LLQUANT_FACTOREVEN.notfactor.d \ + err.D_LLQUANT_FACTORMATCH.d \ + err.D_LLQUANT_FACTORNSTEPS.d \ + err.D_LLQUANT_FACTORSMALL.d \ + err.D_LLQUANT_FACTORTYPE.d \ + err.D_LLQUANT_FACTORVAL.d \ + err.D_LLQUANT_HIGHMATCH.d \ + err.D_LLQUANT_HIGHTYPE.d \ + err.D_LLQUANT_HIGHVAL.d \ + err.D_LLQUANT_LOWMATCH.d \ + err.D_LLQUANT_LOWTYPE.d \ + err.D_LLQUANT_LOWVAL.d \ + err.D_LLQUANT_MAGRANGE.d \ + err.D_LLQUANT_MAGTOOBIG.d \ + err.D_LLQUANT_NSTEPMATCH.d \ + err.D_LLQUANT_NSTEPTYPE.d \ + err.D_LLQUANT_NSTEPVAL.d \ + tst.bases.d \ + tst.bases.d.out \ + tst.basic.d \ + tst.basic.d.out \ + tst.negorder.d \ + tst.negorder.d.out \ + tst.negvalue.d \ + tst.negvalue.d.out \ + tst.normal.d \ + tst.normal.d.out \ + tst.range.d \ + tst.range.d.out \ + tst.steps.d \ + tst.steps.d.out \ + tst.trunc.d \ + tst.trunc.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/mdb/Makefile b/cddl/usr.sbin/dtrace/tests/common/mdb/Makefile new file mode 100644 index 0000000..24a3f88 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/mdb/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.dtracedcmd.ksh \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/mib/Makefile b/cddl/usr.sbin/dtrace/tests/common/mib/Makefile new file mode 100644 index 0000000..ef3a05d --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/mib/Makefile @@ -0,0 +1,19 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.icmp.ksh \ + tst.tcp.ksh \ + tst.udp.ksh \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/misc/Makefile b/cddl/usr.sbin/dtrace/tests/common/misc/Makefile new file mode 100644 index 0000000..31de20b --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/misc/Makefile @@ -0,0 +1,30 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PRAGMA_OPTSET.d \ + tst.badopt.d \ + tst.boolopt.d \ + tst.boolopt.d.out \ + tst.dofmax.ksh \ + tst.dynopt.d \ + tst.dynopt.d.out \ + tst.enablerace.ksh \ + tst.haslam.d \ + tst.include.ksh \ + tst.macroglob.ksh \ + tst.macroglob.ksh.out \ + tst.roch.d \ + tst.schrock.ksh \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/multiaggs/Makefile b/cddl/usr.sbin/dtrace/tests/common/multiaggs/Makefile new file mode 100644 index 0000000..e21c90a --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/multiaggs/Makefile @@ -0,0 +1,34 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PRINTA_AGGKEY.d \ + err.D_PRINTA_AGGPROTO.d \ + tst.many.d \ + tst.many.d.out \ + tst.same.d \ + tst.same.d.out \ + tst.sort.d \ + tst.sort.d.out \ + tst.sortpos.d \ + tst.sortpos.d.out \ + tst.tuplecompat.d \ + tst.tuplecompat.d.out \ + tst.zero.d \ + tst.zero.d.out \ + tst.zero2.d \ + tst.zero2.d.out \ + tst.zero3.d \ + tst.zero3.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/nfs/Makefile b/cddl/usr.sbin/dtrace/tests/common/nfs/Makefile new file mode 100644 index 0000000..446c35e --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/nfs/Makefile @@ -0,0 +1,19 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.call.d \ + tst.call3.d \ + +TESTEXES= \ + + +CFILES= \ + tst.call.c \ + tst.call3.c \ + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/offsetof/Makefile b/cddl/usr.sbin/dtrace/tests/common/offsetof/Makefile new file mode 100644 index 0000000..375aecb --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/offsetof/Makefile @@ -0,0 +1,28 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_OFFSETOF_BITFIELD.bitfield.d \ + err.D_OFFSETOF_TYPE.badtype.d \ + err.D_OFFSETOF_TYPE.notsou.d \ + err.D_UNKNOWN.OffsetofNULL.d \ + err.D_UNKNOWN.badmemb.d \ + tst.OffsetofAlias.d \ + tst.OffsetofArith.d \ + tst.OffsetofUnion.d \ + tst.struct.d \ + tst.struct.d.out \ + tst.union.d \ + tst.union.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/operators/Makefile b/cddl/usr.sbin/dtrace/tests/common/operators/Makefile new file mode 100644 index 0000000..08bbfe6 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/operators/Makefile @@ -0,0 +1,18 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.ternary.d \ + tst.ternary.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/pid/Makefile b/cddl/usr.sbin/dtrace/tests/common/pid/Makefile new file mode 100644 index 0000000..faa5ac8 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/pid/Makefile @@ -0,0 +1,69 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PDESC_ZERO.badlib.d \ + err.D_PDESC_ZERO.badproc1.d \ + err.D_PROC_BADPID.badproc2.d \ + err.D_PROC_CREATEFAIL.many.d \ + err.D_PROC_FUNC.badfunc.d \ + err.D_PROC_LIB.libdash.d \ + err.D_PROC_NAME.alldash.d \ + err.D_PROC_NAME.badname.d \ + err.D_PROC_NAME.globdash.d \ + err.D_PROC_OFF.toobig.d \ + tst.addprobes.ksh \ + tst.args1.d \ + tst.coverage.d \ + tst.emptystack.d \ + tst.emptystack.d.out \ + tst.float.d \ + tst.fork.d \ + tst.gcc.d \ + tst.killonerror.ksh \ + tst.main.ksh \ + tst.manypids.ksh \ + tst.newprobes.ksh \ + tst.newprobes.ksh.out \ + tst.probemod.ksh \ + tst.provregex1.ksh \ + tst.provregex2.ksh \ + tst.provregex2.ksh.out \ + tst.provregex3.ksh \ + tst.provregex3.ksh.out \ + tst.provregex4.ksh \ + tst.provregex4.ksh.out \ + tst.ret1.d \ + tst.ret2.d \ + tst.vfork.d \ + tst.weak1.d \ + tst.weak2.d \ + +TESTEXES= \ + err.D_PDESC_ZERO.badlib.exe \ + err.D_PROC_CREATEFAIL.many.exe \ + err.D_PROC_FUNC.badfunc.exe \ + err.D_PROC_LIB.libdash.exe \ + err.D_PROC_NAME.alldash.exe \ + err.D_PROC_NAME.badname.exe \ + err.D_PROC_NAME.globdash.exe \ + err.D_PROC_OFF.toobig.exe \ + tst.coverage.exe \ + tst.emptystack.exe \ + +CFILES= \ + tst.args1.c \ + tst.float.c \ + tst.fork.c \ + tst.gcc.c \ + tst.ret1.c \ + tst.ret2.c \ + tst.vfork.c \ + tst.weak1.c \ + tst.weak2.c \ + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/plockstat/Makefile b/cddl/usr.sbin/dtrace/tests/common/plockstat/Makefile new file mode 100644 index 0000000..0f36f34 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/plockstat/Makefile @@ -0,0 +1,19 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.available.d \ + tst.libmap.d \ + +TESTEXES= \ + tst.available.exe \ + tst.libmap.exe \ + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/pointers/Makefile b/cddl/usr.sbin/dtrace/tests/common/pointers/Makefile new file mode 100644 index 0000000..2953c54 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/pointers/Makefile @@ -0,0 +1,48 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.BadAlign.d \ + err.D_ADDROF_VAR.ArrayVar.d \ + err.D_ADDROF_VAR.DynamicVar.d \ + err.D_ADDROF_VAR.agg.d \ + err.D_DEREF_NONPTR.noptr.d \ + err.D_DEREF_VOID.VoidPointerDeref.d \ + err.D_OP_ARRFUN.ArrayAssignment.d \ + err.D_OP_INCOMPAT.VoidPointerArith.d \ + err.D_OP_LVAL.AddressChange.d \ + err.D_OP_PTR.NonPointerAccess.d \ + err.D_OP_PTR.badpointer.d \ + err.D_OP_SOU.BadPointerAccess.d \ + err.D_OP_SOU.badpointer.d \ + err.InvalidAddress1.d \ + err.InvalidAddress2.d \ + err.InvalidAddress3.d \ + err.InvalidAddress4.d \ + err.InvalidAddress5.d \ + tst.ArrayPointer1.d \ + tst.ArrayPointer2.d \ + tst.ArrayPointer3.d \ + tst.GlobalVar.d \ + tst.IntegerArithmetic1.d \ + tst.PointerArithmetic1.d \ + tst.PointerArithmetic2.d \ + tst.PointerArithmetic3.d \ + tst.PointerAssignment.d \ + tst.ValidPointer1.d \ + tst.ValidPointer2.d \ + tst.VoidCast.d \ + tst.basic1.d \ + tst.basic2.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/pragma/Makefile b/cddl/usr.sbin/dtrace/tests/common/pragma/Makefile new file mode 100644 index 0000000..86010ac --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/pragma/Makefile @@ -0,0 +1,30 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PRAGERR.d \ + err.D_PRAGMA_DEPEND.main.d \ + err.D_PRAGMA_INVAL.d \ + err.D_PRAGMA_MALFORM.d \ + err.D_PRAGMA_UNUSED.UnusedPragma.d \ + err.circlibdep.ksh \ + err.invalidlibdep.ksh \ + tst.libchain.ksh \ + tst.libdep.ksh \ + tst.libdepfullyconnected.ksh \ + tst.libdepsepdir.ksh \ + tst.temporal.ksh \ + tst.temporal2.ksh \ + tst.temporal3.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/predicates/Makefile b/cddl/usr.sbin/dtrace/tests/common/predicates/Makefile new file mode 100644 index 0000000..67cfabe --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/predicates/Makefile @@ -0,0 +1,25 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PRED_SCALAR.NonScalarPred.d \ + err.D_SYNTAX.invalid.d \ + err.D_SYNTAX.operr.d \ + tst.argsnotcached.d \ + tst.basics.d \ + tst.basics.d.out \ + tst.complex.d \ + tst.complex.d.out \ + tst.predcache.ksh \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/preprocessor/Makefile b/cddl/usr.sbin/dtrace/tests/common/preprocessor/Makefile new file mode 100644 index 0000000..8108375 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/preprocessor/Makefile @@ -0,0 +1,53 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_IDENT_UNDEF.afterprobe.d \ + err.D_PRAGCTL_INVAL.tabdefine.d \ + err.D_SYNTAX.withoutpound.d \ + err.defincomp.d \ + err.ifdefelsenotendif.d \ + err.ifdefincomp.d \ + err.ifdefnotendif.d \ + err.incompelse.d \ + err.mulelse.d \ + tst.ifdef.d \ + tst.ifdef.d.out \ + tst.ifndef.d \ + tst.ifndef.d.out \ + tst.ifnotdef.d \ + tst.ifnotdef.d.out \ + tst.logicaland.d \ + tst.logicaland.d.out \ + tst.logicalandor.d \ + tst.logicalandor.d.out \ + tst.logicalor.d \ + tst.logicalor.d.out \ + tst.muland.d \ + tst.muland.d.out \ + tst.mulor.d \ + tst.mulor.d.out \ + tst.precondi.d \ + tst.precondi.d.out \ + tst.predicatedeclare.d \ + tst.preexp.d \ + tst.preexp.d.out \ + tst.preexpelse.d \ + tst.preexpelse.d.out \ + tst.preexpif.d \ + tst.preexpif.d.out \ + tst.preexpifelse.d \ + tst.preexpifelse.d.out \ + tst.withinprobe.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/print/Makefile b/cddl/usr.sbin/dtrace/tests/common/print/Makefile new file mode 100644 index 0000000..4360794 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/print/Makefile @@ -0,0 +1,32 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PRINT_AGG.bad.d \ + err.D_PRINT_VOID.bad.d \ + err.D_PROTO_LEN.bad.d \ + tst.array.d \ + tst.array.d.out \ + tst.bitfield.d \ + tst.bitfield.d.out \ + tst.dyn.d \ + tst.enum.d \ + tst.enum.d.out \ + tst.primitive.d \ + tst.primitive.d.out \ + tst.struct.d \ + tst.struct.d.out \ + tst.xlate.d \ + tst.xlate.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/printa/Makefile b/cddl/usr.sbin/dtrace/tests/common/printa/Makefile new file mode 100644 index 0000000..c972db3 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/printa/Makefile @@ -0,0 +1,40 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PRINTA_AGGARG.badagg.d \ + err.D_PRINTA_AGGARG.badfmt.d \ + err.D_PRINTA_AGGARG.badval.d \ + err.D_PRINTA_PROTO.bad.d \ + err.D_PRINTF_ARG_TYPE.jstack.d \ + err.D_PRINTF_ARG_TYPE.stack.d \ + err.D_PRINTF_ARG_TYPE.ustack.d \ + tst.basics.d \ + tst.basics.d.out \ + tst.def.d \ + tst.def.d.out \ + tst.dynwidth.d \ + tst.dynwidth.d.out \ + tst.fmt.d \ + tst.fmt.d.out \ + tst.largeusersym.ksh \ + tst.many.d \ + tst.manyval.d \ + tst.manyval.d.out \ + tst.stack.d \ + tst.tuple.d \ + tst.tuple.d.out \ + tst.walltimestamp.ksh \ + tst.walltimestamp.ksh.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/printf/Makefile b/cddl/usr.sbin/dtrace/tests/common/printf/Makefile new file mode 100644 index 0000000..d4658b1 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/printf/Makefile @@ -0,0 +1,68 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PRINTF_AGG_CONV.aggfmt.d \ + err.D_PRINTF_ARG_EXTRA.toomany.d \ + err.D_PRINTF_ARG_EXTRA.widths.d \ + err.D_PRINTF_ARG_FMT.badfmt.d \ + err.D_PRINTF_ARG_PROTO.novalue.d \ + err.D_PRINTF_ARG_TYPE.aggarg.d \ + err.D_PRINTF_ARG_TYPE.recursive.d \ + err.D_PRINTF_DYN_PROTO.noprec.d \ + err.D_PRINTF_DYN_PROTO.nowidth.d \ + err.D_PRINTF_DYN_TYPE.badprec.d \ + err.D_PRINTF_DYN_TYPE.badwidth.d \ + err.D_PROTO_LEN.toofew.d \ + err.D_SYNTAX.badconv1.d \ + err.D_SYNTAX.badconv2.d \ + err.D_SYNTAX.badconv3.d \ + tst.basics.d \ + tst.basics.d.out \ + tst.flags.d \ + tst.flags.d.out \ + tst.hello.d \ + tst.hello.d.out \ + tst.ints.d \ + tst.ints.d.out \ + tst.precs.d \ + tst.precs.d.out \ + tst.print-f.d \ + tst.print-f.d.out \ + tst.printT.ksh \ + tst.printT.ksh.out \ + tst.printY.ksh \ + tst.printY.ksh.out \ + tst.printcont.d \ + tst.printcont.d.out \ + tst.printeE.d \ + tst.printeE.d.out \ + tst.printgG.d \ + tst.printgG.d.out \ + tst.rawfmt.d \ + tst.rawfmt.d.out \ + tst.signs.d \ + tst.signs.d.out \ + tst.str.d \ + tst.str.d.out \ + tst.sym.d \ + tst.sym.d.out \ + tst.uints.d \ + tst.uints.d.out \ + tst.widths.d \ + tst.widths.d.out \ + tst.widths1.d \ + tst.wp.d \ + tst.wp.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/privs/Makefile b/cddl/usr.sbin/dtrace/tests/common/privs/Makefile new file mode 100644 index 0000000..02cd83b --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/privs/Makefile @@ -0,0 +1,24 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.fds.ksh \ + tst.func_access.ksh \ + tst.getf.ksh \ + tst.kpriv.ksh \ + tst.op_access.ksh \ + tst.procpriv.ksh \ + tst.providers.ksh \ + tst.unpriv_funcs.ksh \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/probes/Makefile b/cddl/usr.sbin/dtrace/tests/common/probes/Makefile new file mode 100644 index 0000000..463290b --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/probes/Makefile @@ -0,0 +1,36 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PDESC_ZERO.probeqtn.d \ + err.D_PDESC_ZERO.probestar.d \ + err.D_PDESC_ZERO.tickstar.d \ + err.D_SYNTAX.assign.d \ + err.D_SYNTAX.declare.d \ + err.D_SYNTAX.declarein.d \ + err.D_SYNTAX.lbraces.d \ + err.D_SYNTAX.probespec.d \ + err.D_SYNTAX.rbraces.d \ + err.D_SYNTAX.recdec.d \ + tst.basic1.d \ + tst.check.d \ + tst.declare.d \ + tst.declareafter.d \ + tst.emptyprobe.d \ + tst.pragma.d \ + tst.pragmaaftertab.d \ + tst.pragmainside.d \ + tst.pragmaoutside.d \ + tst.probestar.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/proc/Makefile b/cddl/usr.sbin/dtrace/tests/common/proc/Makefile new file mode 100644 index 0000000..5ab672b --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/proc/Makefile @@ -0,0 +1,30 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.create.ksh \ + tst.discard.ksh \ + tst.exec.ksh \ + tst.execfail.ENOENT.ksh \ + tst.execfail.ksh \ + tst.exitcore.ksh \ + tst.exitexit.ksh \ + tst.exitkilled.ksh \ + tst.signal.ksh \ + tst.sigwait.d \ + tst.startexit.ksh \ + +TESTEXES= \ + + +CFILES= \ + tst.sigwait.c \ + + +LDADD.tst.sigwait.exe+= -lrt +DPADD.tst.sigwait.exe+= ${LIBRT} + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile b/cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile new file mode 100644 index 0000000..cb6ad9f --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile @@ -0,0 +1,53 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PDESC_ZERO.profile.d \ + err.D_PDESC_ZEROonens.d \ + err.D_PDESC_ZEROonensec.d \ + err.D_PDESC_ZEROoneus.d \ + err.D_PDESC_ZEROoneusec.d \ + tst.argtest.d \ + tst.argtest.d.out \ + tst.basic.d \ + tst.basic.d.out \ + tst.func.ksh \ + tst.mod.ksh \ + tst.profilehz.d \ + tst.profilehz.d.out \ + tst.profilems.d \ + tst.profilems.d.out \ + tst.profilemsec.d \ + tst.profilemsec.d.out \ + tst.profilenhz.d \ + tst.profilenhz.d.out \ + tst.profilens.d \ + tst.profilens.d.out \ + tst.profilensec.d \ + tst.profilensec.d.out \ + tst.profiles.d \ + tst.profiles.d.out \ + tst.profilesec.d \ + tst.profilesec.d.out \ + tst.profileus.d \ + tst.profileus.d.out \ + tst.profileusec.d \ + tst.profileusec.d.out \ + tst.sym.ksh \ + tst.ufunc.ksh \ + tst.ufuncsort.ksh \ + tst.ufuncsort.ksh.out \ + tst.umod.ksh \ + tst.usym.ksh \ + +TESTEXES= \ + + +CFILES= \ + tst.ufuncsort.c \ + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/providers/Makefile b/cddl/usr.sbin/dtrace/tests/common/providers/Makefile new file mode 100644 index 0000000..763d60b --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/providers/Makefile @@ -0,0 +1,44 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PDESC_INVAL.wrongdec4.d \ + err.D_PDESC_ZERO.nonprofile.d \ + err.D_PDESC_ZERO.wrongdec1.d \ + err.D_PDESC_ZERO.wrongdec2.d \ + err.D_PDESC_ZERO.wrongdec3.d \ + tst.basics.d \ + tst.basics.d.out \ + tst.beginexit.d \ + tst.beginprof.d \ + tst.beginprof.d.out \ + tst.probattrs.d \ + tst.probattrs.d.out \ + tst.probefunc.d \ + tst.probefunc.d.out \ + tst.probemod.d \ + tst.probemod.d.out \ + tst.probename.d \ + tst.probename.d.out \ + tst.probprov.d \ + tst.probprov.d.out \ + tst.profend.d \ + tst.profend.d.out \ + tst.profexit.d \ + tst.profexit.d.out \ + tst.trace.d \ + tst.trace.d.out \ + tst.twoprof.d \ + tst.twoprof.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/raise/Makefile b/cddl/usr.sbin/dtrace/tests/common/raise/Makefile new file mode 100644 index 0000000..f84ac52 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/raise/Makefile @@ -0,0 +1,21 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.raise1.d \ + tst.raise2.d \ + tst.raise3.d \ + +TESTEXES= \ + + +CFILES= \ + tst.raise1.c \ + tst.raise2.c \ + tst.raise3.c \ + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/rates/Makefile b/cddl/usr.sbin/dtrace/tests/common/rates/Makefile new file mode 100644 index 0000000..a3f54f5 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/rates/Makefile @@ -0,0 +1,21 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.aggrate.d \ + tst.aggrate.d.out \ + tst.statusrate.d \ + tst.switchrate.d \ + tst.switchrate.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/safety/Makefile b/cddl/usr.sbin/dtrace/tests/common/safety/Makefile new file mode 100644 index 0000000..0e88ea3 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/safety/Makefile @@ -0,0 +1,54 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.basename.d \ + tst.caller.d \ + tst.cleanpath.d \ + tst.copyin.d \ + tst.copyin2.d \ + tst.ddi_pathname.d \ + tst.dirname.d \ + tst.errno.d \ + tst.execname.d \ + tst.gid.d \ + tst.hton.d \ + tst.index.d \ + tst.msgdsize.d \ + tst.msgsize.d \ + tst.null.d \ + tst.pid.d \ + tst.ppid.d \ + tst.progenyof.d \ + tst.random.d \ + tst.rw.d \ + tst.shortstr.d \ + tst.stack.d \ + tst.stackdepth.d \ + tst.stddev.d \ + tst.strchr.d \ + tst.strjoin.d \ + tst.strstr.d \ + tst.strtok.d \ + tst.substr.d \ + tst.ucaller.d \ + tst.uid.d \ + tst.unalign.d \ + tst.uregs.d \ + tst.ustack.d \ + tst.ustackdepth.d \ + tst.vahole.d \ + tst.violentdeath.ksh \ + tst.zonename.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/scalars/Makefile b/cddl/usr.sbin/dtrace/tests/common/scalars/Makefile new file mode 100644 index 0000000..2f471a6 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/scalars/Makefile @@ -0,0 +1,37 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_ARR_LOCAL.thisarray.d \ + err.D_DECL_CLASS.selfthis.d \ + err.D_DECL_CLASS.thisself.d \ + err.D_DECL_IDRED.errval.d \ + err.D_OP_INCOMPAT.dec.err.d \ + err.D_OP_INCOMPAT.dupgtype.d \ + err.D_OP_INCOMPAT.dupltype.d \ + err.D_OP_INCOMPAT.dupttype.d \ + err.D_SYNTAX.declare.d \ + err.bigglobal.d \ + err.biglocal.d \ + tst.basicvar.d \ + tst.basicvar.d.out \ + tst.localvar.d \ + tst.misc.d \ + tst.self.d \ + tst.selfarray.d \ + tst.selfarray2.d \ + tst.selfthis.d \ + tst.this.d \ + tst.thisself.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/sched/Makefile b/cddl/usr.sbin/dtrace/tests/common/sched/Makefile new file mode 100644 index 0000000..adf8c98 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/sched/Makefile @@ -0,0 +1,19 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.enqueue.d \ + tst.oncpu.d \ + tst.stackdepth.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/scripting/Makefile b/cddl/usr.sbin/dtrace/tests/common/scripting/Makefile new file mode 100644 index 0000000..0bb10cf --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/scripting/Makefile @@ -0,0 +1,49 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_MACRO_UNDEF.invalidargs.d \ + err.D_OP_LVAL.rdonly.d \ + err.D_OP_WRITE.usepidmacro.d \ + err.D_SYNTAX.concat.d \ + err.D_SYNTAX.desc.d \ + err.D_SYNTAX.inval.d \ + err.D_SYNTAX.pid.d \ + tst.D_MACRO_UNUSED.overflow.ksh \ + tst.arg0.d \ + tst.arguments.ksh \ + tst.assign.d \ + tst.basic.d \ + tst.egid.d \ + tst.egid.ksh \ + tst.euid.d \ + tst.euid.ksh \ + tst.gid.d \ + tst.gid.ksh \ + tst.pgid.d \ + tst.pid.d \ + tst.ppid.d \ + tst.ppid.ksh \ + tst.projid.d \ + tst.projid.ksh \ + tst.quite.d \ + tst.sid.d \ + tst.sid.ksh \ + tst.stringmacro.ksh \ + tst.taskid.d \ + tst.taskid.ksh \ + tst.trace.d \ + tst.uid.d \ + tst.uid.ksh \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/sdt/Makefile b/cddl/usr.sbin/dtrace/tests/common/sdt/Makefile new file mode 100644 index 0000000..598cc69 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/sdt/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.sdtargs.d \ + +TESTEXES= \ + + +CFILES= \ + tst.sdtargs.c \ + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/sizeof/Makefile b/cddl/usr.sbin/dtrace/tests/common/sizeof/Makefile new file mode 100644 index 0000000..6b146b0 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/sizeof/Makefile @@ -0,0 +1,31 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_IDENT_BADREF.SizeofAssoc.d \ + err.D_IDENT_UNDEF.UnknownSymbol.d \ + err.D_SIZEOF_TYPE.badstruct.d \ + err.D_SIZEOF_TYPE.d \ + err.D_SYNTAX.SizeofBadType.d \ + tst.SizeofArray.d \ + tst.SizeofDataTypes.d \ + tst.SizeofExpression.d \ + tst.SizeofNULL.d \ + tst.SizeofStrConst.d \ + tst.SizeofStrConst.d.out \ + tst.SizeofString1.d \ + tst.SizeofString1.d.out \ + tst.SizeofString2.d \ + tst.SizeofString2.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/speculation/Makefile b/cddl/usr.sbin/dtrace/tests/common/speculation/Makefile new file mode 100644 index 0000000..f17ded9 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/speculation/Makefile @@ -0,0 +1,75 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + bug.1001148.SpecSizeVariations.d \ + err.BufSizeVariations1.d \ + err.BufSizeVariations2.d \ + err.D_ACT_SPEC.SpeculateWithBreakPoint.d \ + err.D_ACT_SPEC.SpeculateWithChill.d \ + err.D_ACT_SPEC.SpeculateWithCopyOut.d \ + err.D_ACT_SPEC.SpeculateWithCopyOutStr.d \ + err.D_ACT_SPEC.SpeculateWithPanic.d \ + err.D_ACT_SPEC.SpeculateWithRaise.d \ + err.D_ACT_SPEC.SpeculateWithStop.d \ + err.D_AGG_COMM.AggAftCommit.d \ + err.D_AGG_SPEC.SpeculateWithAvg.d \ + err.D_AGG_SPEC.SpeculateWithCount.d \ + err.D_AGG_SPEC.SpeculateWithLquant.d \ + err.D_AGG_SPEC.SpeculateWithMax.d \ + err.D_AGG_SPEC.SpeculateWithMin.d \ + err.D_AGG_SPEC.SpeculateWithQuant.d \ + err.D_AGG_SPEC.SpeculateWithStddev.d \ + err.D_AGG_SPEC.SpeculateWithSum.d \ + err.D_COMM_COMM.CommitAftCommit.d \ + err.D_COMM_COMM.DisjointCommit.d \ + err.D_COMM_DREC.CommitAftDataRec.d \ + err.D_DREC_COMM.DataRecAftCommit.d \ + err.D_DREC_COMM.ExitAfterCommit.d \ + err.D_EXIT_SPEC.ExitAftSpec.d \ + err.D_PRAGMA_MALFORM.NspecExpr.d \ + err.D_PRAGMA_OPTSET.HugeNspecValue.d \ + err.D_PRAGMA_OPTSET.InvalidSpecSize.d \ + err.D_PRAGMA_OPTSET.NegSpecSize.d \ + err.D_PROTO_LEN.SpecNoId.d \ + err.D_SPEC_COMM.SpecAftCommit.d \ + err.D_SPEC_DREC.SpecAftDataRec.d \ + err.D_SPEC_SPEC.SpecAftSpec.d \ + err.NegativeBufSize.d \ + err.NegativeNspec.d \ + err.NegativeSpecSize.d \ + err.SpecSizeVariations1.d \ + err.SpecSizeVariations2.d \ + tst.CommitAfterDiscard.d \ + tst.CommitWithZero.d \ + tst.DataRecAftDiscard.d \ + tst.DiscardAftCommit.d \ + tst.DiscardAftDataRec.d \ + tst.DiscardAftDiscard.d \ + tst.DiscardWithZero.d \ + tst.ExitAftDiscard.d \ + tst.NoSpecBuffer.d \ + tst.SpecSizeVariations1.d \ + tst.SpecSizeVariations2.d \ + tst.SpecSizeVariations3.d \ + tst.SpeculateWithRandom.d \ + tst.SpeculationCommit.d \ + tst.SpeculationDiscard.d \ + tst.SpeculationID.d \ + tst.SpeculationWithZero.d \ + tst.TwoSpecBuffers.d \ + tst.negcommit.d \ + tst.negspec.d \ + tst.zerosize.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/stability/Makefile b/cddl/usr.sbin/dtrace/tests/common/stability/Makefile new file mode 100644 index 0000000..8fb9afa --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/stability/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_ATTR_MIN.MinAttributes.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/stack/Makefile b/cddl/usr.sbin/dtrace/tests/common/stack/Makefile new file mode 100644 index 0000000..ca01f42 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/stack/Makefile @@ -0,0 +1,22 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_STACK_PROTO.bad.d \ + err.D_STACK_SIZE.d \ + err.D_USTACK_FRAMES.bad.d \ + err.D_USTACK_PROTO.bad.d \ + err.D_USTACK_STRSIZE.bad.d \ + tst.default.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/stackdepth/Makefile b/cddl/usr.sbin/dtrace/tests/common/stackdepth/Makefile new file mode 100644 index 0000000..8e94963 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/stackdepth/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.default.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/stop/Makefile b/cddl/usr.sbin/dtrace/tests/common/stop/Makefile new file mode 100644 index 0000000..a03d9aa --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/stop/Makefile @@ -0,0 +1,19 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.stop1.d \ + tst.stop2.d \ + +TESTEXES= \ + + +CFILES= \ + tst.stop1.c \ + tst.stop2.c \ + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/strlen/Makefile b/cddl/usr.sbin/dtrace/tests/common/strlen/Makefile new file mode 100644 index 0000000..0fec541 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/strlen/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.strlen1.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/strtoll/Makefile b/cddl/usr.sbin/dtrace/tests/common/strtoll/Makefile new file mode 100644 index 0000000..8af2d41 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/strtoll/Makefile @@ -0,0 +1,20 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.BaseTooLarge.d \ + err.BaseTooSmall.d \ + tst.strtoll.d \ + tst.strtoll.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/struct/Makefile b/cddl/usr.sbin/dtrace/tests/common/struct/Makefile new file mode 100644 index 0000000..fb039f2 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/struct/Makefile @@ -0,0 +1,31 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_ADDROF_VAR.StructPointer.d \ + err.D_DECL_COMBO.StructWithoutColon.d \ + err.D_DECL_COMBO.StructWithoutColon1.d \ + err.D_DECL_INCOMPLETE.circular.d \ + err.D_DECL_INCOMPLETE.order.d \ + err.D_DECL_INCOMPLETE.order2.d \ + err.D_DECL_INCOMPLETE.recursive.d \ + err.D_DECL_INCOMPLETE.simple.d \ + err.D_DECL_VOIDOBJ.baddec.d \ + err.D_PROTO_ARG.DupStructAssoc.d \ + tst.StructAssoc.d \ + tst.StructDataTypes.d \ + tst.StructInside.d \ + tst.clauselocal.d \ + tst.clauselocal.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/syscall/Makefile b/cddl/usr.sbin/dtrace/tests/common/syscall/Makefile new file mode 100644 index 0000000..035fdf0 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/syscall/Makefile @@ -0,0 +1,18 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.args.d \ + tst.openret.ksh \ + +TESTEXES= \ + + +CFILES= \ + tst.args.c \ + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/sysevent/Makefile b/cddl/usr.sbin/dtrace/tests/common/sysevent/Makefile new file mode 100644 index 0000000..496360e --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/sysevent/Makefile @@ -0,0 +1,19 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.post.d \ + tst.post_chan.d \ + +TESTEXES= \ + + +CFILES= \ + tst.post.c \ + tst.post_chan.c \ + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/tick-n/Makefile b/cddl/usr.sbin/dtrace/tests/common/tick-n/Makefile new file mode 100644 index 0000000..d843b9a --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/tick-n/Makefile @@ -0,0 +1,38 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PDESC_ZERO.tick.d \ + err.D_PDESC_ZEROonens.d \ + err.D_PDESC_ZEROonensec.d \ + err.D_PDESC_ZEROoneus.d \ + err.D_PDESC_ZEROoneusec.d \ + tst.tickarg0.d \ + tst.tickms.d \ + tst.tickms.d.out \ + tst.tickmsec.d \ + tst.tickmsec.d.out \ + tst.tickns.d \ + tst.tickns.d.out \ + tst.ticknsec.d \ + tst.ticknsec.d.out \ + tst.ticks.d \ + tst.ticks.d.out \ + tst.ticksec.d \ + tst.ticksec.d.out \ + tst.tickus.d \ + tst.tickus.d.out \ + tst.tickusec.d \ + tst.tickusec.d.out \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/trace/Makefile b/cddl/usr.sbin/dtrace/tests/common/trace/Makefile new file mode 100644 index 0000000..e1500f2 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/trace/Makefile @@ -0,0 +1,24 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PROTO_LEN.bad.d \ + err.D_TRACE_AGG.bad.d \ + err.D_TRACE_VOID.bad.d \ + tst.dyn.d \ + tst.misc.d \ + tst.qstring.d \ + tst.qstring.d.out \ + tst.string.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/tracemem/Makefile b/cddl/usr.sbin/dtrace/tests/common/tracemem/Makefile new file mode 100644 index 0000000..5ba7b6f --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/tracemem/Makefile @@ -0,0 +1,26 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_PROTO_ARG.badsize.d \ + err.D_PROTO_LEN.toofew.d \ + err.D_TRACEMEM_ADDR.badaddr.d \ + err.D_TRACEMEM_ARGS.d \ + err.D_TRACEMEM_DYNSIZE.d \ + err.D_TRACEMEM_SIZE.negsize.d \ + err.D_TRACEMEM_SIZE.zerosize.d \ + tst.dynsize.d \ + tst.dynsize.d.out \ + tst.rootvp.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/translators/Makefile b/cddl/usr.sbin/dtrace/tests/common/translators/Makefile new file mode 100644 index 0000000..4d57edf --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/translators/Makefile @@ -0,0 +1,51 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_DECL_TYPERED.BadTransDecl.d \ + err.D_OP_INCOMPLETE.NonExistentInput1.d \ + err.D_SYNTAX.BadTransDecl1.d \ + err.D_SYNTAX.BadTransDecl3.d \ + err.D_SYNTAX.BadTransDecl4.d \ + err.D_TYPE_MEMBER.NonExistentInput2.d \ + err.D_XLATE_INCOMPAT.BadInputType1.d \ + err.D_XLATE_MEMB.NonExistentOutput2.d \ + err.D_XLATE_NONE.BadTransDecl6.d \ + err.D_XLATE_REDECL.RepeatTransDecl.d \ + err.D_XLATE_SOU.BadTransDecl8.d \ + err.D_XLATE_SOU.BadTransInt.d \ + err.D_XLATE_SOU.NonExistentOutput1.d \ + tst.CircularTransDecl.d \ + tst.EmptyTransDecl.d \ + tst.ForwardTag.d \ + tst.InputAliasTrans.d \ + tst.InputIntTrans.d \ + tst.OutputAliasTrans.d \ + tst.PartialDereferencing.d \ + tst.PartialOutputTransDefn.d \ + tst.ProcModelTrans.d \ + tst.RepeatDeclaration.d \ + tst.SimultaneousTranslators.d \ + tst.StructureAssignment.d \ + tst.TestTransStability1.ksh \ + tst.TestTransStability1.ksh.out \ + tst.TestTransStability2.ksh \ + tst.TestTransStability2.ksh.out \ + tst.TransNonPointer.d \ + tst.TransOutputPointer.d \ + tst.TransPointer.d \ + tst.TranslateSelf.d \ + tst.UnionInputTrans.d \ + tst.UnionOutputTrans.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/typedef/Makefile b/cddl/usr.sbin/dtrace/tests/common/typedef/Makefile new file mode 100644 index 0000000..477fd74 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/typedef/Makefile @@ -0,0 +1,21 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_DECL_IDRED.DupTypeDef.d \ + err.D_SYNTAX.BadExistingTypedef.d \ + err.D_SYNTAX.TypedefInClause.d \ + tst.ChainTypedef.d \ + tst.TypedefDataAssign.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/types/Makefile b/cddl/usr.sbin/dtrace/tests/common/types/Makefile new file mode 100644 index 0000000..1a3d326 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/types/Makefile @@ -0,0 +1,69 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_CAST_INVAL.badcast.d \ + err.D_CG_DYN.ResultDynType.d \ + err.D_CHR_OFLOW.charconst.d \ + err.D_DECL_BADCLASS.bad.d \ + err.D_DECL_CHARATTR.badtype3.d \ + err.D_DECL_COMBO.badtype4.d \ + err.D_DECL_COMBO.badtype5.d \ + err.D_DECL_ENCONST.badeval.d \ + err.D_DECL_ENOFLOW.enoflow.d \ + err.D_DECL_ENOFLOW.enuflow.d \ + err.D_DECL_SCOPE.scopeop.d \ + err.D_DECL_USELESS.baddec.d \ + err.D_OP_ACT.badcond.d \ + err.D_OP_ARITH.badoperand.d \ + err.D_OP_INCOMPAT.badassign.d \ + err.D_OP_INT.badbitop.d \ + err.D_OP_INT.badshift.d \ + err.D_OP_SCALAR.badcond.d \ + err.D_OP_SCALAR.badincop.d \ + err.D_OP_SCALAR.badlogop.d \ + err.D_PROTO_LEN.badcond1.d \ + err.D_SYNTAX.badenum.d \ + err.D_SYNTAX.badid.d \ + err.D_SYNTAX.badstruct.d \ + err.D_UNKNOWN.badtype1.d \ + err.D_UNKNOWN.badtype2.d \ + err.D_UNKNOWN.dupenum.d \ + err.D_UNKNOWN.dupstruct.d \ + err.D_XLATE_REDECL.ResultDynType.d \ + tst.assignops.d \ + tst.badshiftops.d \ + tst.basics.d \ + tst.basics.d.out \ + tst.bitops.d \ + tst.charconstants.d \ + tst.complex.d \ + tst.condexpr.d \ + tst.const.d \ + tst.constants.d \ + tst.conv.d \ + tst.enum.d \ + tst.intincop.d \ + tst.intops.d \ + tst.inttypes.d \ + tst.ptrincop.d \ + tst.ptrops.d \ + tst.relenum.d \ + tst.relstring.d \ + tst.shiftops.d \ + tst.stringconstants.d \ + tst.struct.d \ + tst.typedef.d \ + tst.unaryop.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/uctf/Makefile b/cddl/usr.sbin/dtrace/tests/common/uctf/Makefile new file mode 100644 index 0000000..493d550 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/uctf/Makefile @@ -0,0 +1,41 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.invalidpid.d \ + err.invalidpid2.d \ + err.invalidpid3.d \ + err.invalidtype.ksh \ + err.invalidtype2.ksh \ + err.user64mode.ksh \ + tst.aouttype.ksh \ + tst.chasestrings.ksh \ + tst.chasestrings.ksh.out \ + tst.libtype.ksh \ + tst.linkmap.ksh \ + tst.pidprint.ksh \ + tst.pidprinttarg.ksh \ + tst.printtype.ksh \ + tst.printtype.ksh.out \ + tst.printtypetarg.ksh \ + tst.userlandkey.ksh \ + tst.userlandkey.ksh.out \ + tst.userstrings.ksh \ + tst.userstrings.ksh.out \ + +TESTEXES= \ + + +CFILES= \ + tst.aouttype.c \ + tst.chasestrings.c \ + tst.libtype.c \ + tst.printtype.c \ + + +WITH_CTF=YES + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/union/Makefile b/cddl/usr.sbin/dtrace/tests/common/union/Makefile new file mode 100644 index 0000000..69e0ca8 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/union/Makefile @@ -0,0 +1,27 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + err.D_ADDROF_VAR.UnionPointer.d \ + err.D_DECL_COMBO.UnionWithoutColon.d \ + err.D_DECL_COMBO.UnionWithoutColon1.d \ + err.D_DECL_INCOMPLETE.circular.d \ + err.D_DECL_INCOMPLETE.order.d \ + err.D_DECL_INCOMPLETE.recursive.d \ + err.D_DECL_INCOMPLETE.simple.d \ + err.D_PROTO_ARG.DupUnionAssoc.d \ + tst.UnionAssoc.d \ + tst.UnionDataTypes.d \ + tst.UnionInside.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/usdt/Makefile b/cddl/usr.sbin/dtrace/tests/common/usdt/Makefile new file mode 100644 index 0000000..f6fa49b --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/usdt/Makefile @@ -0,0 +1,65 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + argmap.d \ + args.d \ + forker.d \ + prov.d \ + tst.andpid.ksh \ + tst.argmap.d \ + tst.args.d \ + tst.badguess.ksh \ + tst.corruptenv.ksh \ + tst.dlclose1.ksh \ + tst.dlclose1.ksh.out \ + tst.dlclose2.ksh \ + tst.dlclose2.ksh.out \ + tst.dlclose3.ksh \ + tst.eliminate.ksh \ + tst.enabled.ksh \ + tst.enabled.ksh.out \ + tst.enabled2.ksh \ + tst.enabled2.ksh.out \ + tst.entryreturn.ksh \ + tst.entryreturn.ksh.out \ + tst.fork.ksh \ + tst.fork.ksh.out \ + tst.forker.ksh \ + tst.guess32.ksh \ + tst.guess64.ksh \ + tst.header.ksh \ + tst.include.ksh \ + tst.linkpriv.ksh \ + tst.linkunpriv.ksh \ + tst.multiple.ksh \ + tst.multiple.ksh.out \ + tst.multiprov.ksh \ + tst.multiprov.ksh.out \ + tst.nodtrace.ksh \ + tst.noprobes.ksh \ + tst.noreap.ksh \ + tst.noreapring.ksh \ + tst.onlyenabled.ksh \ + tst.reap.ksh \ + tst.reeval.ksh \ + tst.static.ksh \ + tst.static.ksh.out \ + tst.static2.ksh \ + tst.static2.ksh.out \ + tst.user.ksh \ + tst.user.ksh.out \ + +TESTEXES= \ + + +CFILES= \ + tst.argmap.c \ + tst.args.c \ + tst.forker.c \ + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/ustack/Makefile b/cddl/usr.sbin/dtrace/tests/common/ustack/Makefile new file mode 100644 index 0000000..960c407 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/ustack/Makefile @@ -0,0 +1,20 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.bigstack.d \ + tst.depth.ksh \ + tst.spin.ksh \ + +TESTEXES= \ + + +CFILES= \ + tst.bigstack.c \ + tst.spin.c \ + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/vars/Makefile b/cddl/usr.sbin/dtrace/tests/common/vars/Makefile new file mode 100644 index 0000000..5b47557 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/vars/Makefile @@ -0,0 +1,23 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.gid.d \ + tst.nullassign.d \ + tst.ppid.d \ + tst.ucaller.ksh \ + tst.ucaller.ksh.out \ + tst.uid.d \ + tst.walltimestamp.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/common/version/Makefile b/cddl/usr.sbin/dtrace/tests/common/version/Makefile new file mode 100644 index 0000000..0491cea --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/version/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +TESTFILES= \ + tst.1.0.d \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../Makefile.inc1" diff --git a/cddl/usr.sbin/dtrace/tests/tools/dtest.sh b/cddl/usr.sbin/dtrace/tests/tools/dtest.sh new file mode 100755 index 0000000..e60837b --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/tools/dtest.sh @@ -0,0 +1,129 @@ +# $FreeBSD$ + +usage() +{ + cat >&2 <<__EOF__ +A harness for test cases in the DTrace test suite. + +usage: $(basename $0) +__EOF__ + exit 1 +} + +gettag() +{ + local tag + + tag=$(basename $1) + tag=${tag#*.} + tag=${tag%%[a-z.]*} + echo $tag +} + +runtest() +{ + local dflags exe exstatus pid retval status + + exstatus=0 + retval=0 + + case $TFILE in + drp.DTRACEDROP_*.d|err.*.d|tst.*.d) + case $TFILE in + drp.DTRACEDROP_*.d) + dflags="-x droptags" + tag=$(gettag "$TFILE") + ;; + err.D_*.d) + exstatus=1 + dflags="-x errtags" + tag=$(gettag "$TFILE") + ;; + err.*.d) + exstatus=1 + ;; + esac + + exe=${TFILE%.*}.exe + if [ -f "$exe" -a -x "$exe" ]; then + ./$exe & + pid=$! + dflags="$dflags ${pid}" + fi + + dtrace -C -s "${TFILE}" $dflags >$STDOUT 2>$STDERR + status=$? + + if [ $status -ne $exstatus ]; then + ERRMSG="dtrace exited with status ${status}, expected ${exstatus}" + retval=1 + elif [ -n "${tag}" ] && ! grep -Fq " [${tag}] " ${STDERR}; then + ERRMSG="dtrace's error output did not contain expected tag ${tag}" + retval=1 + fi + + if [ -n "$pid" ]; then + kill -0 $pid >/dev/null 2>&1 && kill -9 $pid >/dev/null 2>&1 + wait + fi + ;; + err.*.ksh|tst.*.ksh) + expr "$TFILE" : 'err.*' >/dev/null && exstatus=1 + + ksh "$TFILE" /usr/sbin/dtrace >$STDOUT 2>$STDERR + status=$? + + if [ $status -ne $exstatus ]; then + ERRMSG="script exited with status ${status}, expected ${exstatus}" + retval=1 + fi + ;; + *) + ERRMSG="unexpected test file name $TFILE" + retval=1 + ;; + esac + + return $retval +} + +[ $# -eq 1 ] || usage + +readonly STDERR=$(mktemp) +readonly STDOUT=$(mktemp) +readonly TFILE=$(basename $1) +readonly EXOUT=${TFILE}.out + +kldstat -q -m dtrace_test || kldload dtrace_test +cd $(dirname $1) +runtest +RESULT=$? + +if [ $RESULT -eq 0 -a -f $EXOUT -a -r $EXOUT ] && \ + ! cmp $STDOUT $EXOUT >/dev/null 2>&1; then + ERRMSG="test output mismatch" + RESULT=1 +fi + +if [ $RESULT -ne 0 ]; then + echo "test $TFILE failed: $ERRMSG" >&2 + if [ $(stat -f '%z' $STDOUT) -gt 0 ]; then + cat >&2 <<__EOF__ +test stdout: +-- +$(cat $STDOUT) +-- +__EOF__ + fi + if [ $(stat -f '%z' $STDERR) -gt 0 ]; then + cat >&2 <<__EOF__ +test stderr: +-- +$(cat $STDERR) +-- +__EOF__ + fi +fi + +rm -f $STDERR $STDOUT +exit $RESULT diff --git a/cddl/usr.sbin/dtrace/tests/tools/exclude.sh b/cddl/usr.sbin/dtrace/tests/tools/exclude.sh new file mode 100755 index 0000000..a42773d --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/tools/exclude.sh @@ -0,0 +1,194 @@ +# $FreeBSD$ + +# This file lists DTrace tests which are known to fail or hang/crash the +# system. They were pulled from the legacy DTrace test infrastructure in +# tools/tests/dtrace and may be out of date. +# +# Tests are listed here generally because one or more of the following is true: +# +# 1) The test is broken (usually because it assumes it's running on Solaris and +# the test encodes some sort of Solarisism). +# 2) The functionality being tested is buggy (often but not always the result +# of a FreeBSD-specific bug). +# 3) The test relies on DTrace functionality that's not yet available in FreeBSD +# (e.g. tests for a specific SDT provider that we don't have). +# +# An end goal is to remove this file, concentrating first on instances of +# 1) and 2). +# +# The SKIP variable contains tests that should not be executed at all. The +# EXFAIL variable contains tests that are expected to fail when run. Please +# avoid adding tests to SKIP unless it really is necessary; with EXFAIL, tests +# that begin passing as the result of a change are visible in the test summary. + +exclude() +{ + eval $1=\"\$$1\\n$2\" +} + +exclude EXFAIL common/aggs/tst.subr.d +exclude EXFAIL common/dtraceUtil/tst.DataModel32.d.ksh +exclude EXFAIL common/dtraceUtil/tst.ELFGenerationOut.d.ksh +exclude EXFAIL common/dtraceUtil/tst.ELFGenerationWithO.d.ksh +exclude EXFAIL common/funcs/tst.copyin.d +exclude EXFAIL common/funcs/tst.copyinto.d +exclude EXFAIL common/funcs/tst.ddi_pathname.d +exclude EXFAIL common/io/tst.fds.d +exclude EXFAIL common/ip/tst.ipv4localudp.ksh +exclude EXFAIL common/mdb/tst.dtracedcmd.ksh +exclude EXFAIL common/misc/tst.dofmax.ksh +exclude EXFAIL common/misc/tst.include.ksh +exclude EXFAIL common/pragma/tst.libchain.ksh +exclude EXFAIL common/safety/tst.copyin2.d +exclude EXFAIL common/safety/tst.msgdsize.d +exclude EXFAIL common/safety/tst.msgsize.d +exclude EXFAIL common/safety/tst.zonename.d +exclude EXFAIL common/scalars/tst.misc.d +exclude EXFAIL common/scalars/tst.selfarray2.d +exclude EXFAIL common/sched/tst.enqueue.d +exclude EXFAIL common/speculation/tst.SpecSizeVariations3.d +exclude EXFAIL common/tracemem/err.D_TRACEMEM_ADDR.badaddr.d +exclude EXFAIL common/translators/tst.TestTransStability2.ksh +exclude EXFAIL common/types/tst.struct.d +exclude EXFAIL common/types/tst.typedef.d + +# We don't have a cpc provider. +exclude SKIP common/cpc/err.D_PDESC_ZERO.lowfrequency.d +exclude SKIP common/cpc/err.D_PDESC_ZERO.malformedoverflow.d +exclude SKIP common/cpc/err.D_PDESC_ZERO.nonexistentevent.d +exclude SKIP common/cpc/err.cpcvscpustatpart1.ksh +exclude SKIP common/cpc/err.cpcvscpustatpart2.ksh +exclude SKIP common/cpc/err.cputrackfailtostart.ksh +exclude SKIP common/cpc/err.cputrackterminates.ksh +exclude SKIP common/cpc/err.toomanyenablings.d +exclude SKIP common/cpc/tst.allcpus.ksh +exclude SKIP common/cpc/tst.genericevent.d +exclude SKIP common/cpc/tst.platformevent.ksh + +# We don't have a mib provider. +exclude EXFAIL common/mib/tst.icmp.ksh +exclude EXFAIL common/mib/tst.tcp.ksh +exclude EXFAIL common/mib/tst.udp.ksh + +# At the moment dtrace(1) always needs to run as root. +exclude SKIP common/privs/tst.fds.ksh +exclude SKIP common/privs/tst.func_access.ksh +exclude SKIP common/privs/tst.getf.ksh +exclude SKIP common/privs/tst.op_access.ksh +exclude SKIP common/privs/tst.procpriv.ksh +exclude SKIP common/privs/tst.providers.ksh +exclude SKIP common/privs/tst.unpriv_funcs.ksh + +# These tests hang for reasons unknown. +exclude SKIP common/buffering/tst.ring3.d +exclude SKIP common/funcs/tst.chill.ksh +exclude SKIP common/funcs/tst.index.d + +# No Java support at the moment. +exclude EXFAIL common/java_api/tst.Abort.ksh +exclude EXFAIL common/java_api/tst.Bean.ksh +exclude EXFAIL common/java_api/tst.Close.ksh +exclude EXFAIL common/java_api/tst.Drop.ksh +exclude EXFAIL common/java_api/tst.Enable.ksh +exclude EXFAIL common/java_api/tst.FunctionLookup.ksh +exclude EXFAIL common/java_api/tst.GetAggregate.ksh +exclude EXFAIL common/java_api/tst.MaxConsumers.ksh +exclude EXFAIL common/java_api/tst.MultiAggPrinta.ksh +exclude EXFAIL common/java_api/tst.ProbeData.ksh +exclude EXFAIL common/java_api/tst.ProbeDescription.ksh +exclude EXFAIL common/java_api/tst.StateMachine.ksh +exclude EXFAIL common/java_api/tst.StopLock.ksh + +# Expects specific formatting from banner(6). +exclude EXFAIL common/aggs/tst.aggpackbanner.ksh + +# Test assumes we're running on a Solaris kernel. +exclude EXFAIL common/misc/tst.roch.d +exclude EXFAIL common/predicates/tst.argsnotcached.d +exclude EXFAIL common/safety/tst.vahole.d + +# Tests that depend on the plockstat provider. +exclude EXFAIL common/plockstat/tst.available.d +exclude EXFAIL common/plockstat/tst.libmap.d +exclude EXFAIL common/usdt/tst.andpid.ksh + +# Depends on java. +exclude SKIP common/drops/drp.DTRACEDROP_STKSTROVERFLOW.d + +# Interrupt priority isn't relevant on FreeBSD. +exclude SKIP common/builtinvar/tst.ipl.d +exclude SKIP common/builtinvar/tst.ipl1.d + +# These tests rely on being able to find a host via broadcast pings. +exclude EXFAIL common/ip/tst.ipv4remotetcp.ksh +exclude EXFAIL common/ip/tst.ipv4remoteudp.ksh +exclude EXFAIL common/ip/tst.ipv6remoteicmp.ksh +exclude EXFAIL common/ip/tst.ipv4remoteicmp.ksh + +# FreeBSD never places tcpcbs in the TIME_WAIT state, so the probe never fires. +exclude EXFAIL common/ip/tst.localtcpstate.ksh +exclude EXFAIL common/ip/tst.remotetcpstate.ksh + +# Depends on the number of probes in /bin/sh and the current DOF limit. +exclude EXFAIL common/pid/err.D_PROC_CREATEFAIL.many.d + +# Tries to enable pid$target:libc::entry, though there's no "libc" module. +# Currently unsure as to whether this might be a libproc bug. +exclude EXFAIL common/pid/tst.probemod.ksh + +# Assumes date(1) has a pid$target::main:return probe. +exclude EXFAIL common/pid/tst.newprobes.ksh + +# libproc+librtld_db don't handle dlopen(2) yet. +exclude EXFAIL common/pid/tst.provregex2.ksh +exclude EXFAIL common/pid/tst.provregex4.ksh + +# libproc doesn't properly handle probe sites that correspond to multiple +# symbols. +exclude EXFAIL common/pid/tst.weak1.d +exclude EXFAIL common/pid/tst.weak2.d + +# This test checks for a leading tab on a line before #define. That is illegal +# on Solaris, but the clang pre-processor on FreeBSD is happy with code like +# that. +exclude EXFAIL common/preprocessor/err.D_PRAGCTL_INVAL.tabdefine.d + +# This test uses proc:::signal-handle, which we don't appear to have. +exclude EXFAIL common/proc/tst.signal.ksh + +# This test uses proc:::lwp-start, which we don't appear to have. +exclude EXFAIL common/proc/tst.startexit.ksh + +# This test causes a panic at the moment because fbt instruments the lock class' +# lc_owned method. +exclude SKIP common/safety/tst.rw.d + +# Depends on some implementation details of the runtime linker. +exclude EXFAIL common/vars/tst.ucaller.ksh + +# These rely on process attributes that FreeBSD doesn't carry. +exclude EXFAIL common/scripting/tst.projid.ksh +exclude EXFAIL common/scripting/tst.taskid.ksh + +# This test expects its test program to be installed without CTF data, but +# the rest of the programs for this feature need CTF data. Not yet sure how +# to build that. +exclude EXFAIL common/uctf/tst.libtype.ksh + +# libproc doesn't have linkmap support yet. +exclude EXFAIL common/uctf/tst.linkmap.ksh + +# Uses Sun-specific compiler options. +exclude EXFAIL common/usdt/tst.badguess.ksh +exclude EXFAIL common/usdt/tst.guess32.ksh +exclude EXFAIL common/usdt/tst.guess64.ksh + +# Generated headers include , so _DTRACE_VERSION is always defined. +exclude EXFAIL common/usdt/tst.nodtrace.ksh + +# The second dtrace -G invocation returns an error with "no probes found," which +# makes sense to me. Not yet sure what the expected behaviour is here. +exclude EXFAIL common/usdt/tst.static2.ksh + +# Uses the Solaris-specific ppriv(1). +exclude EXFAIL common/usdt/tst.user.ksh diff --git a/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh b/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh new file mode 100755 index 0000000..bf0e181 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh @@ -0,0 +1,85 @@ +# $FreeBSD$ + +usage() +{ + cat <<__EOF__ >&2 +usage: $(basename $0) + +This script regenerates the DTrace test suite makefiles. It should be run +whenever \$srcdir/cddl/contrib/opensolaris/cmd/dtrace/test/tst is modified. +__EOF__ + exit 1 +} + +# Format a file list for use in a make(1) variable assignment: take the +# basename of each input file and append " \" to it. +fmtflist() +{ + awk 'function bn(f) { + sub(".*/", "", f) + return f + } + {print " ", bn($1), " \\"}' +} + +genmakefile() +{ + local basedir=$1 + + local tdir=${CONTRIB_TESTDIR}/${basedir} + local tfiles=$(find $tdir -type f -a \ + \( -name \*.d -o -name \*.ksh -o -name \*.out \) | sort | fmtflist) + local tcfiles=$(find $tdir -type f -a -name \*.c | sort | fmtflist) + local texes=$(find $tdir -type f -a -name \*.exe | sort | fmtflist) + + # One-off variable definitions. + local special + if [ "$basedir" = proc ]; then + special=" +LDADD.tst.sigwait.exe+= -lrt +DPADD.tst.sigwait.exe+= \${LIBRT} +" + elif [ "$basedir" = uctf ]; then + special=" +WITH_CTF=YES +" + fi + + local makefile=$(mktemp) + cat <<__EOF__ > $makefile +# \$FreeBSD$ + +# +# This Makefile was generated by \$srcdir${ORIGINDIR#${TOPDIR}}/genmakefiles.sh. +# + +TESTFILES= \\ +$tfiles + +TESTEXES= \\ +$texes + +CFILES= \\ +$tcfiles + +$special +.include "../../Makefile.inc1" +__EOF__ + + mv -f $makefile ${ORIGINDIR}/../common/${basedir}/Makefile +} + +set -e + +if [ $# -ne 0 ]; then + usage +fi + +readonly ORIGINDIR=$(realpath $(dirname $0)) +readonly TOPDIR=$(realpath ${ORIGINDIR}/../../../../..) +readonly CONTRIB_TESTDIR=${TOPDIR}/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common + +# Generate a Makefile for each test group under common/. +for dir in $(find ${CONTRIB_TESTDIR} -mindepth 1 -maxdepth 1 -type d); do + genmakefile $(basename $dir) +done diff --git a/cddl/usr.sbin/dtrace/tests/tools/gentest.sh b/cddl/usr.sbin/dtrace/tests/tools/gentest.sh new file mode 100755 index 0000000..9c34b79 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/tools/gentest.sh @@ -0,0 +1,110 @@ +# $FreeBSD$ + +usage() +{ + cat <<__EOF__ >&2 +Generate ATF test cases from a set of DTrace tests. + +usage: sh $(basename $0) [-e ] [] + + excludes: A shell script which defines test cases that are to be skipped, + or aren't expected to pass. + category: The test category, in the form of /. For example, + "common/aggs" is the test category for D aggregations. + testfiles: The test files for the tests in the specified category. +__EOF__ + exit 1 +} + +gentestcase() +{ + local mod tcase tfile + + tfile=$1 + tcase=$2 + mod=$3 + + cat <<__EOF__ +atf_test_case $tcase +${tcase}_head() +{ + atf_set 'descr' 'DTrace test ${CATEGORY}/${tfile}' +} +${tcase}_body() +{ + $mod + atf_check -s exit:0 -o empty -e empty \\ + "\$(atf_get_srcdir)/../../dtest" "\$(atf_get_srcdir)/${tfile}" +} +__EOF__ +} + +gentestcases() +{ + local mod tcase tfile tfiles + + eval tfiles=\$$1 + mod=$2 + + for tfile in ${tfiles}; do + case $tfile in + drp.*.d|err.*.d|tst.*.d|*.ksh) + # Test names need to be mangled for ATF. + tcase=$(echo "$tfile" | tr '.-' '_') + gentestcase "$tfile" "$tcase" "$mod" + TCASES="$TCASES $tcase" + ;; + esac + done +} + +set -e + +# +# Parse arguments. +# +case $1 in +-e) + shift; EXCLUDES=$1; shift + ;; +esac + +CATEGORY=$1 +shift +if ! expr "$CATEGORY" : '[^/]*/[^/]*' >/dev/null 2>&1; then + usage +fi +FEATURE=$(basename ${CATEGORY}) +ARCH=$(dirname ${CATEGORY}) + +# +# Remove skipped tests and expected failures from the main test list. +# +. $EXCLUDES +EXFAILS=$(echo -e "$EXFAIL" | grep "^${CATEGORY}/" | xargs basename -a) +SKIPS=$(echo -e "$SKIP" | grep "^${CATEGORY}/" | xargs basename -a) + +FILELIST=$(mktemp) +trap 'rm -f $FILELIST' EXIT + +echo "$@" | tr ' ' '\n' | xargs basename -a | sort > ${FILELIST} +TFILES=$(printf '%s\n%s' "$EXFAILS" "$SKIPS" | sort | comm -13 /dev/stdin $FILELIST) + +# +# Generate test cases. +# +gentestcases SKIPS "atf_skip \"test may hang or cause system instability\"" +gentestcases EXFAILS "atf_expect_fail \"test is known to fail\"" +gentestcases TFILES + +# +# Generate the test init function. +# +cat <<__EOF__ +atf_init_test_cases() +{ +$(for tcase in ${TCASES}; do echo " atf_add_test_case $tcase"; done) +} +__EOF__ + +rm -f $FILELIST diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index bb48ef8..80c9461 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -53,6 +53,168 @@ usr.bin .. usr.sbin + dtrace + common + aggs + .. + arithmetic + .. + arrays + .. + assocs + .. + begin + .. + bitfields + .. + buffering + .. + builtinvar + .. + cg + .. + clauses + .. + cpc + .. + decls + .. + drops + .. + dtraceUtil + .. + end + .. + enum + .. + error + .. + exit + .. + fbtprovider + .. + funcs + .. + grammar + .. + include + .. + inline + .. + io + .. + ip + .. + java_api + .. + json + .. + lexer + .. + llquantize + .. + mdb + .. + mib + .. + misc + .. + multiaggs + .. + offsetof + .. + operators + .. + pid + .. + plockstat + .. + pointers + .. + pragma + .. + predicates + .. + preprocessor + .. + print + .. + printa + .. + printf + .. + privs + .. + probes + .. + proc + .. + profile-n + .. + providers + .. + raise + .. + rates + .. + safety + .. + scalars + .. + sched + .. + scripting + .. + sdt + .. + sizeof + .. + speculation + .. + stability + .. + stack + .. + stackdepth + .. + stop + .. + strlen + .. + strtoll + .. + struct + .. + syscall + .. + sysevent + .. + tick-n + .. + trace + .. + tracemem + .. + translators + .. + typedef + .. + types + .. + uctf + .. + union + .. + usdt + .. + ustack + .. + vars + .. + version + .. + .. + .. .. .. etc -- cgit v1.1 From 26a774214d8d03cd6f66b1ba20979ab10fc4bbcd Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 9 Feb 2017 22:04:56 +0000 Subject: MFC r258903,r264487,r271699,r288415: r258903 (by markj): Enable some previously-disabled DTrace tests for umod, ufunc and usym. They expect the installed ksh binary to be named "ksh", which is not the case when it's installed on FreeBSD via the shells/ksh93 port. Allow for it to be "ksh93" as well so that the tests can actually pass. r264487 (by markj): Replace a few Solarisisms with their corresponding FreeBSDisms to make a few printf tests pass. r271699 (by markj): Implement a workaround to allow this test program to be compiled with clang. It seems that if a pragma is used to define a weak alias for a local function, the pragma must appear after the function is defined. PR: 193056 r288415 (by markj): MFV r288408: 6266 harden dtrace_difo_chunksize() with respect to malicious DIF illumos/illumos-gate@395c7a3dcfc66b8b671dc4b3c4a2f0ca26449922 Author: Bryan Cantrill --- .../cmd/dtrace/test/tst/common/pid/tst.weak2.c | 4 +- .../cmd/dtrace/test/tst/common/printf/tst.basics.d | 2 +- .../dtrace/test/tst/common/printf/tst.basics.d.out | 2 +- .../cmd/dtrace/test/tst/common/printf/tst.str.d | 2 +- .../dtrace/test/tst/common/printf/tst.str.d.out | 2 +- .../cmd/dtrace/test/tst/common/printf/tst.sym.d | 2 +- .../dtrace/test/tst/common/printf/tst.sym.d.out | 2 +- .../cmd/dtrace/test/tst/common/privs/tst.kpriv.ksh | 112 +++++++++++++++++++++ .../dtrace/test/tst/common/profile-n/tst.ufunc.ksh | 2 +- .../dtrace/test/tst/common/profile-n/tst.umod.ksh | 2 +- .../dtrace/test/tst/common/profile-n/tst.usym.ksh | 2 +- .../dtrace/test/tst/common/scalars/err.bigglobal.d | 26 +++++ .../dtrace/test/tst/common/scalars/err.biglocal.d | 26 +++++ .../contrib/opensolaris/uts/common/dtrace/dtrace.c | 67 ++++++++++-- .../opensolaris/uts/common/sys/dtrace_impl.h | 19 ++-- tools/test/dtrace/Makefile | 5 - 16 files changed, 245 insertions(+), 32 deletions(-) create mode 100644 cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/privs/tst.kpriv.ksh create mode 100644 cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.bigglobal.d create mode 100644 cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.biglocal.d diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c index 42d8cde..756745d 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c @@ -35,14 +35,14 @@ * leading underscores. */ -#pragma weak _go = go - static int go(int a) { return (a + 1); } +#pragma weak _go = go + static void handle(int sig) { diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d index 8d4bb81..10dc61d 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d @@ -44,7 +44,7 @@ BEGIN printf("\n"); - printf("%%a = %a\n", &`kmem_alloc); + printf("%%a = %a\n", &`malloc); printf("%%c = %c\n", i); printf("%%d = %d\n", i); printf("%%hd = %hd\n", (short)i); diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d.out index 55c1222..1d27405 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d.out +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d.out @@ -1,5 +1,5 @@ -%a = genunix`kmem_alloc +%a = kernel`malloc %c = a %d = 97 %hd = 97 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d index a740413..67d7749 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d @@ -36,6 +36,6 @@ BEGIN { - printf("sysname = %s", `utsname.sysname); + printf("sysname = %s", `ostype); exit(0); } diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d.out index ba31981..82d597b 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d.out +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d.out @@ -1 +1 @@ -sysname = SunOS +sysname = FreeBSD diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d index 32bc682..c2cf77d 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d @@ -38,6 +38,6 @@ BEGIN { - printf("symbol = %a", &`kmem_alloc); + printf("symbol = %a", &`malloc); exit(0); } diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d.out index 5ed9d8e..7f645e1 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d.out +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d.out @@ -1 +1 @@ -symbol = kernel`kmem_alloc +symbol = kernel`malloc diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/privs/tst.kpriv.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/privs/tst.kpriv.ksh new file mode 100644 index 0000000..da776d0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/privs/tst.kpriv.ksh @@ -0,0 +1,112 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2015, Joyent, Inc. All rights reserved. +# + +err=/tmp/err.$$ + +ppriv -s A=basic,dtrace_user $$ + +# +# When we lack dtrace_kernel, we expect to not be able to get at kernel memory +# via any subroutine or other vector. +# +# trace(func((void *)&\`utsname)); } +/usr/sbin/dtrace -wq -Cs /dev/stdin 2> $err < /dev/null +script | tee /dev/fd/2 | egrep 'ksh(93)?`[a-zA-Z_]' > /dev/null status=$? kill $child diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.umod.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.umod.ksh index 6ca823f..8be34ec 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.umod.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.umod.ksh @@ -62,7 +62,7 @@ child=$! # # The only thing we can be sure of here is that ksh is doing some work. # -script | tee /dev/fd/2 | grep -w ksh > /dev/null +script | tee /dev/fd/2 | egrep -w 'ksh(93)?' > /dev/null status=$? kill $child diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.usym.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.usym.ksh index b1a3ab9..8842d2b 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.usym.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.usym.ksh @@ -63,7 +63,7 @@ child=$! # This test is essentially the same as that in the ufunc test; see that # test for the rationale. # -script | tee /dev/fd/2 | grep 'ksh`[a-zA-Z_]' > /dev/null +script | tee /dev/fd/2 | egrep 'ksh(93)?`[a-zA-Z_]' > /dev/null status=$? kill $child diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.bigglobal.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.bigglobal.d new file mode 100644 index 0000000..a50a759 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.bigglobal.d @@ -0,0 +1,26 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2015, Joyent, Inc. All rights reserved. + */ + +struct mrbig { + char toomany[100000]; +}; + +struct mrbig mrbig; + +BEGIN +{ + mrbig.toomany[0] = '!'; + exit(0); +} diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.biglocal.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.biglocal.d new file mode 100644 index 0000000..08a2a4c --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.biglocal.d @@ -0,0 +1,26 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright (c) 2015, Joyent, Inc. All rights reserved. + */ + +struct mrbig { + char toomany[100000]; +}; + +this struct mrbig mrbig; + +BEGIN +{ + this->mrbig.toomany[0] = '!'; + exit(0); +} diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c index a087e6e..cb12cee 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c +++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c @@ -155,7 +155,7 @@ int dtrace_destructive_disallow = 0; dtrace_optval_t dtrace_nonroot_maxsize = (16 * 1024 * 1024); size_t dtrace_difo_maxsize = (256 * 1024); dtrace_optval_t dtrace_dof_maxsize = (8 * 1024 * 1024); -size_t dtrace_global_maxsize = (16 * 1024); +size_t dtrace_statvar_maxsize = (16 * 1024); size_t dtrace_actions_max = (16 * 1024); size_t dtrace_retain_max = 1024; dtrace_optval_t dtrace_helper_actions_max = 128; @@ -699,13 +699,33 @@ dtrace_canstore_statvar(uint64_t addr, size_t sz, dtrace_statvar_t **svars, int nsvars) { int i; + size_t maxglobalsize, maxlocalsize; + + if (nsvars == 0) + return (0); + + maxglobalsize = dtrace_statvar_maxsize; + maxlocalsize = (maxglobalsize + sizeof (uint64_t)) * NCPU; for (i = 0; i < nsvars; i++) { dtrace_statvar_t *svar = svars[i]; + uint8_t scope; + size_t size; - if (svar == NULL || svar->dtsv_size == 0) + if (svar == NULL || (size = svar->dtsv_size) == 0) continue; + scope = svar->dtsv_var.dtdv_scope; + + /* + * We verify that our size is valid in the spirit of providing + * defense in depth: we want to prevent attackers from using + * DTrace to escalate an orthogonal kernel heap corruption bug + * into the ability to store to arbitrary locations in memory. + */ + VERIFY((scope == DIFV_SCOPE_GLOBAL && size < maxglobalsize) || + (scope == DIFV_SCOPE_LOCAL && size < maxlocalsize)); + if (DTRACE_INRANGE(addr, sz, svar->dtsv_data, svar->dtsv_size)) return (1); } @@ -4455,7 +4475,8 @@ dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs, if (!dtrace_destructive_disallow && dtrace_priv_proc_control(state) && - !dtrace_istoxic(kaddr, size)) { + !dtrace_istoxic(kaddr, size) && + dtrace_canload(kaddr, size, mstate, vstate)) { DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT); dtrace_copyout(kaddr, uaddr, size, flags); DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT); @@ -4470,7 +4491,8 @@ dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs, if (!dtrace_destructive_disallow && dtrace_priv_proc_control(state) && - !dtrace_istoxic(kaddr, size)) { + !dtrace_istoxic(kaddr, size) && + dtrace_strcanload(kaddr, size, mstate, vstate)) { DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT); dtrace_copyoutstr(kaddr, uaddr, size, flags); DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT); @@ -6458,6 +6480,11 @@ dtrace_dif_emulate(dtrace_difo_t *difo, dtrace_mstate_t *mstate, regs[r2] ? regs[r2] : dtrace_strsize_default) + 1; } else { + if (regs[r2] > LONG_MAX) { + *flags |= CPU_DTRACE_ILLOP; + break; + } + tupregs[ttop].dttk_size = regs[r2]; } @@ -9919,9 +9946,10 @@ dtrace_difo_validate(dtrace_difo_t *dp, dtrace_vstate_t *vstate, uint_t nregs, break; } - if (v->dtdv_scope == DIFV_SCOPE_GLOBAL && - vt->dtdt_size > dtrace_global_maxsize) { - err += efunc(i, "oversized by-ref global\n"); + if ((v->dtdv_scope == DIFV_SCOPE_GLOBAL || + v->dtdv_scope == DIFV_SCOPE_LOCAL) && + vt->dtdt_size > dtrace_statvar_maxsize) { + err += efunc(i, "oversized by-ref static\n"); break; } } @@ -10265,6 +10293,9 @@ dtrace_difo_chunksize(dtrace_difo_t *dp, dtrace_vstate_t *vstate) if (srd == 0) return; + if (sval > LONG_MAX) + return; + tupregs[ttop++].dttk_size = sval; } @@ -10326,6 +10357,19 @@ dtrace_difo_chunksize(dtrace_difo_t *dp, dtrace_vstate_t *vstate) */ size = P2ROUNDUP(size, sizeof (uint64_t)); + /* + * Before setting the chunk size, check that we're not going + * to set it to a negative value... + */ + if (size > LONG_MAX) + return; + + /* + * ...and make certain that we didn't badly overflow. + */ + if (size < ksize || size < sizeof (dtrace_dynvar_t)) + return; + if (size > vstate->dtvs_dynvars.dtds_chunksize) vstate->dtvs_dynvars.dtds_chunksize = size; } @@ -13945,6 +13989,8 @@ dtrace_dstate_init(dtrace_dstate_t *dstate, size_t size) if ((dstate->dtds_chunksize = chunksize) == 0) dstate->dtds_chunksize = DTRACE_DYNVAR_CHUNKSIZE; + VERIFY(dstate->dtds_chunksize < LONG_MAX); + if (size < (min = dstate->dtds_chunksize + sizeof (dtrace_dynhash_t))) size = min; @@ -13985,6 +14031,9 @@ dtrace_dstate_init(dtrace_dstate_t *dstate, size_t size) ((uintptr_t)base + hashsize * sizeof (dtrace_dynhash_t)); limit = (uintptr_t)base + size; + VERIFY((uintptr_t)start < limit); + VERIFY((uintptr_t)start >= (uintptr_t)base); + maxper = (limit - (uintptr_t)start) / NCPU; maxper = (maxper / dstate->dtds_chunksize) * dstate->dtds_chunksize; @@ -14010,7 +14059,7 @@ dtrace_dstate_init(dtrace_dstate_t *dstate, size_t size) start = (dtrace_dynvar_t *)limit; } - ASSERT(limit <= (uintptr_t)base + size); + VERIFY(limit <= (uintptr_t)base + size); for (;;) { next = (dtrace_dynvar_t *)((uintptr_t)dvar + @@ -14019,6 +14068,8 @@ dtrace_dstate_init(dtrace_dstate_t *dstate, size_t size) if ((uintptr_t)next + dstate->dtds_chunksize >= limit) break; + VERIFY((uintptr_t)dvar >= (uintptr_t)base && + (uintptr_t)dvar <= (uintptr_t)base + size); dvar->dtdv_next = next; dvar = next; } diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h index a65d1ae..1ec9091 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h +++ b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h @@ -1317,16 +1317,19 @@ extern void dtrace_copystr(uintptr_t, uintptr_t, size_t, volatile uint16_t *); /* * DTrace Assertions * - * DTrace calls ASSERT from probe context. To assure that a failed ASSERT - * does not induce a markedly more catastrophic failure (e.g., one from which - * a dump cannot be gleaned), DTrace must define its own ASSERT to be one that - * may safely be called from probe context. This header file must thus be - * included by any DTrace component that calls ASSERT from probe context, and - * _only_ by those components. (The only exception to this is kernel - * debugging infrastructure at user-level that doesn't depend on calling - * ASSERT.) + * DTrace calls ASSERT and VERIFY from probe context. To assure that a failed + * ASSERT or VERIFY does not induce a markedly more catastrophic failure (e.g., + * one from which a dump cannot be gleaned), DTrace must define its own ASSERT + * and VERIFY macros to be ones that may safely be called from probe context. + * This header file must thus be included by any DTrace component that calls + * ASSERT and/or VERIFY from probe context, and _only_ by those components. + * (The only exception to this is kernel debugging infrastructure at user-level + * that doesn't depend on calling ASSERT.) */ #undef ASSERT +#undef VERIFY +#define VERIFY(EX) ((void)((EX) || \ + dtrace_assfail(#EX, __FILE__, __LINE__))) #ifdef DEBUG #define ASSERT(EX) ((void)((EX) || \ dtrace_assfail(#EX, __FILE__, __LINE__))) diff --git a/tools/test/dtrace/Makefile b/tools/test/dtrace/Makefile index c82d6f7..4b3842b 100644 --- a/tools/test/dtrace/Makefile +++ b/tools/test/dtrace/Makefile @@ -59,7 +59,6 @@ IGNORE= \ ${TESTSRCDIR}/tst/common/proc/tst.discard.ksh \ ${TESTSRCDIR}/tst/common/proc/tst.signal.ksh \ ${TESTSRCDIR}/tst/common/proc/tst.startexit.ksh \ - ${TESTSRCDIR}/tst/common/profile-n/tst.ufuncsort.c \ ${TESTSRCDIR}/tst/common/scalars/tst.misc.d \ ${TESTSRCDIR}/tst/common/scalars/tst.selfarray2.d \ ${TESTSRCDIR}/tst/common/sysevent/tst.post.c \ @@ -115,10 +114,6 @@ NOTWORK+= \ ${TESTSRCDIR}/tst/common/profile-n/tst.func.ksh \ ${TESTSRCDIR}/tst/common/profile-n/tst.mod.ksh \ ${TESTSRCDIR}/tst/common/profile-n/tst.sym.ksh \ - ${TESTSRCDIR}/tst/common/profile-n/tst.ufunc.ksh \ - ${TESTSRCDIR}/tst/common/profile-n/tst.ufuncsort.ksh \ - ${TESTSRCDIR}/tst/common/profile-n/tst.umod.ksh \ - ${TESTSRCDIR}/tst/common/profile-n/tst.usym.ksh \ ${TESTSRCDIR}/tst/common/safety/tst.basename.d \ ${TESTSRCDIR}/tst/common/safety/tst.caller.d \ ${TESTSRCDIR}/tst/common/safety/tst.cleanpath.d \ -- cgit v1.1 From 72ef9ff5b96eef28f0024f16157bf47833200e6d Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 9 Feb 2017 22:14:17 +0000 Subject: MFC r274138,r274149: r274138 (by des): Hook up OpenPAM's own unit tests to the build. r274149 (by markj): Create a directory for the PAM tests. --- etc/mtree/BSD.tests.dist | 2 ++ lib/libpam/libpam/Makefile | 4 ++++ lib/libpam/libpam/tests/Makefile | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 lib/libpam/libpam/tests/Makefile diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index 80c9461..8e0beeb 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -310,6 +310,8 @@ .. libnv .. + libpam + .. librt .. libthr diff --git a/lib/libpam/libpam/Makefile b/lib/libpam/libpam/Makefile index 105748e..cfbe480 100644 --- a/lib/libpam/libpam/Makefile +++ b/lib/libpam/libpam/Makefile @@ -198,4 +198,8 @@ DPSRCS= openpam_static.c INCS= ${HEADERS} ${ADD_HEADERS} INCSDIR= ${INCLUDEDIR}/security +.if ${MK_TESTS} != "no" +SUBDIR+= tests +.endif + .include diff --git a/lib/libpam/libpam/tests/Makefile b/lib/libpam/libpam/tests/Makefile new file mode 100644 index 0000000..2ad64e2 --- /dev/null +++ b/lib/libpam/libpam/tests/Makefile @@ -0,0 +1,19 @@ +# $FreeBSD$ + +OPENPAM = ${.CURDIR}/../../../../contrib/openpam +.PATH: ${OPENPAM}/t + +TESTSDIR = ${TESTSBASE}/lib/libpam + +COMMONSRC = t_file.c t_main.c +.for test in t_openpam_ctype t_openpam_readlinev t_openpam_readword +TAP_TESTS_C += ${test} +SRCS.${test} = ${test}.c ${COMMONSRC} +.endfor +CFLAGS +=-I${OPENPAM}/include -I${OPENPAM}/lib/libpam -I${OPENPAM}/t +WARNS ?= 6 + +DPADD = ${LIBPAM} +LDADD = ${MINUSLPAM} + +.include -- cgit v1.1 From 6b3722162f25f17568ac341320ee8e7ede42bc7e Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 9 Feb 2017 22:49:48 +0000 Subject: MFC r289172,r290254: r289172: Refactor the test/ Makefiles after recent changes to bsd.test.mk (r289158) and netbsd-tests.test.mk (r289151) - Eliminate explicit OBJTOP/SRCTOP setting - Convert all ad hoc NetBSD test integration over to netbsd-tests.test.mk - Remove unnecessary TESTSDIR setting - Use SRCTOP where possible for clarity r290254: Remove unused variable (SRCDIR) --- bin/cat/tests/Makefile | 6 ------ bin/date/tests/Makefile | 2 -- bin/expr/tests/Makefile | 6 ------ bin/ls/tests/Makefile | 2 -- bin/mv/tests/Makefile | 2 -- bin/pax/tests/Makefile | 2 -- bin/pkill/tests/Makefile | 2 -- bin/sh/tests/Makefile | 2 -- bin/sleep/tests/Makefile | 7 +------ bin/test/tests/Makefile | 2 -- bin/tests/Makefile | 4 +--- cddl/lib/tests/Makefile | 4 +--- cddl/sbin/tests/Makefile | 4 +--- cddl/tests/Makefile | 4 +--- cddl/usr.bin/tests/Makefile | 4 +--- cddl/usr.sbin/dtrace/tests/Makefile | 3 +-- cddl/usr.sbin/tests/Makefile | 4 +--- gnu/lib/tests/Makefile | 4 +--- gnu/tests/Makefile | 4 +--- gnu/usr.bin/diff/tests/Makefile | 11 ++++------- gnu/usr.bin/tests/Makefile | 4 +--- lib/atf/libatf-c++/tests/Makefile | 3 +-- lib/atf/libatf-c++/tests/detail/Makefile | 2 +- lib/atf/libatf-c/tests/Makefile | 3 +-- lib/atf/libatf-c/tests/detail/Makefile | 2 +- lib/atf/tests/Makefile | 2 +- lib/atf/tests/test-programs/Makefile | 2 +- lib/libc/tests/Makefile | 2 -- lib/libc/tests/Makefile.netbsd-tests | 6 +++--- lib/libc/tests/c063/Makefile | 2 -- lib/libc/tests/db/Makefile | 2 -- lib/libc/tests/gen/Makefile | 2 -- lib/libc/tests/gen/execve/Makefile | 6 ------ lib/libc/tests/gen/posix_spawn/Makefile | 6 ------ lib/libc/tests/hash/Makefile | 6 ++---- lib/libc/tests/inet/Makefile | 2 -- lib/libc/tests/locale/Makefile | 2 -- lib/libc/tests/net/Makefile | 2 -- lib/libc/tests/net/getaddrinfo/Makefile | 4 ---- lib/libc/tests/regex/Makefile | 2 -- lib/libc/tests/rpc/Makefile | 1 - lib/libc/tests/setjmp/Makefile | 4 ++-- lib/libc/tests/ssp/Makefile | 2 -- lib/libc/tests/stdio/Makefile | 2 -- lib/libc/tests/stdlib/Makefile | 2 -- lib/libc/tests/string/Makefile | 2 -- lib/libc/tests/sys/Makefile | 2 -- lib/libc/tests/termios/Makefile | 2 -- lib/libc/tests/time/Makefile | 2 -- lib/libc/tests/tls/Makefile | 1 - lib/libc/tests/tls/dso/Makefile | 1 - lib/libc/tests/ttyio/Makefile | 2 -- lib/libcrypt/tests/Makefile | 2 -- lib/libmp/tests/Makefile | 2 -- lib/libnv/tests/Makefile | 2 -- lib/libpam/libpam/tests/Makefile | 2 +- lib/librt/tests/Makefile | 6 ------ lib/libthr/tests/Makefile | 4 ---- lib/libthr/tests/dlopen/Makefile | 2 -- lib/libthr/tests/dlopen/dso/Makefile | 2 -- lib/libutil/tests/Makefile | 2 -- lib/msun/tests/Makefile | 4 ---- lib/tests/Makefile | 4 +--- libexec/atf/atf-check/tests/Makefile | 4 +--- libexec/atf/atf-sh/tests/Makefile | 4 +--- libexec/atf/tests/Makefile | 4 +--- libexec/tests/Makefile | 4 +--- sbin/devd/tests/Makefile | 2 -- sbin/dhclient/tests/Makefile | 2 -- sbin/growfs/tests/Makefile | 2 -- sbin/mdconfig/tests/Makefile | 3 --- sbin/tests/Makefile | 4 +--- secure/lib/tests/Makefile | 4 +--- secure/libexec/tests/Makefile | 4 +--- secure/tests/Makefile | 4 +--- secure/usr.bin/tests/Makefile | 4 +--- secure/usr.sbin/tests/Makefile | 4 +--- share/examples/tests/Makefile | 4 +--- share/tests/Makefile | 2 +- tests/etc/Makefile | 2 +- tests/sys/mqueue/Makefile | 2 +- tests/sys/pjdfstest/tests/Makefile | 2 +- usr.bin/apply/tests/Makefile | 2 -- usr.bin/basename/tests/Makefile | 9 ++------- usr.bin/calendar/tests/Makefile | 2 -- usr.bin/cmp/tests/Makefile | 9 +++------ usr.bin/col/tests/Makefile | 2 -- usr.bin/comm/tests/Makefile | 2 -- usr.bin/cut/tests/Makefile | 9 +++------ usr.bin/dirname/tests/Makefile | 9 +++------ usr.bin/file2c/tests/Makefile | 2 -- usr.bin/grep/tests/Makefile | 10 +++------- usr.bin/gzip/tests/Makefile | 9 +++------ usr.bin/join/tests/Makefile | 2 -- usr.bin/jot/tests/Makefile | 2 -- usr.bin/lastcomm/tests/Makefile | 2 -- usr.bin/m4/tests/Makefile | 2 -- usr.bin/ncal/tests/Makefile | 2 -- usr.bin/printf/tests/Makefile | 2 -- usr.bin/sed/tests/Makefile | 2 -- usr.bin/tests/Makefile | 4 +--- usr.bin/truncate/tests/Makefile | 3 +-- usr.bin/uudecode/tests/Makefile | 2 -- usr.bin/uuencode/tests/Makefile | 2 -- usr.bin/xargs/tests/Makefile | 2 -- usr.bin/yacc/tests/Makefile | 4 +--- usr.sbin/etcupdate/tests/Makefile | 2 -- usr.sbin/fstyp/tests/Makefile | 2 -- usr.sbin/newsyslog/tests/Makefile | 2 -- usr.sbin/nmtree/tests/Makefile | 4 +--- usr.sbin/pw/tests/Makefile | 2 -- usr.sbin/sa/tests/Makefile | 2 -- usr.sbin/tests/Makefile | 4 +--- 113 files changed, 67 insertions(+), 304 deletions(-) diff --git a/bin/cat/tests/Makefile b/bin/cat/tests/Makefile index 73f82e1..f68513c 100644 --- a/bin/cat/tests/Makefile +++ b/bin/cat/tests/Makefile @@ -1,11 +1,5 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR}/../../.. -SRCTOP= ${.CURDIR}/../../.. -TESTSRC= ${SRCTOP}/contrib/netbsd-tests/bin/cat - -TESTSDIR= ${TESTSBASE}/bin/cat - NETBSD_ATF_TESTS_SH= cat_test FILESDIR= ${TESTSDIR} diff --git a/bin/date/tests/Makefile b/bin/date/tests/Makefile index d023195..ecce803 100644 --- a/bin/date/tests/Makefile +++ b/bin/date/tests/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/bin/date - ATF_TESTS_SH= format_string_test .include diff --git a/bin/expr/tests/Makefile b/bin/expr/tests/Makefile index 80c130c..21b0e99 100644 --- a/bin/expr/tests/Makefile +++ b/bin/expr/tests/Makefile @@ -1,11 +1,5 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR}/../../.. -SRCTOP= ${.CURDIR}/../../.. -TESTSRC= ${SRCTOP}/contrib/netbsd-tests/bin/expr - -TESTSDIR= ${TESTSBASE}/bin/expr - NETBSD_ATF_TESTS_SH= expr_test ATF_TESTS_SH_SED_expr_test+= -e 's/eval expr/eval expr --/g' diff --git a/bin/ls/tests/Makefile b/bin/ls/tests/Makefile index ba8038c..89a2e8c 100644 --- a/bin/ls/tests/Makefile +++ b/bin/ls/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/bin/ls - ATF_TESTS_SH+= ls_tests # This seems like overkill, but the idea in mind is that all of the testcases # should be runnable as !root diff --git a/bin/mv/tests/Makefile b/bin/mv/tests/Makefile index 3d437ef..229d96e 100644 --- a/bin/mv/tests/Makefile +++ b/bin/mv/tests/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/bin/mv - TAP_TESTS_SH= legacy_test .include diff --git a/bin/pax/tests/Makefile b/bin/pax/tests/Makefile index 1f27c18..8334fea 100644 --- a/bin/pax/tests/Makefile +++ b/bin/pax/tests/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/bin/pax - TAP_TESTS_PERL= legacy_test .include diff --git a/bin/pkill/tests/Makefile b/bin/pkill/tests/Makefile index a4a2c91..be46707 100644 --- a/bin/pkill/tests/Makefile +++ b/bin/pkill/tests/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/bin/pkill - TAP_TESTS_SH= pgrep-F_test TAP_TESTS_SH+= pgrep-LF_test TAP_TESTS_SH+= pgrep-P_test diff --git a/bin/sh/tests/Makefile b/bin/sh/tests/Makefile index d10156c..a9abc80 100644 --- a/bin/sh/tests/Makefile +++ b/bin/sh/tests/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/bin/sh - TESTS_SUBDIRS+= builtins TESTS_SUBDIRS+= errors TESTS_SUBDIRS+= execution diff --git a/bin/sleep/tests/Makefile b/bin/sleep/tests/Makefile index 9b286e6..6fc95f3 100644 --- a/bin/sleep/tests/Makefile +++ b/bin/sleep/tests/Makefile @@ -1,12 +1,7 @@ # $FreeBSD$ -TESTSRC= ${.CURDIR}/../../../contrib/netbsd-tests/bin/sleep -.PATH: ${TESTSRC} - .include -TESTSDIR= ${TESTSBASE}/bin/sleep -ATF_TESTS_SH= sleep_test -ATF_TESTS_SH_SRC_sleep_test= t_sleep.sh +NETBSD_ATF_TESTS_SH= sleep_test .include diff --git a/bin/test/tests/Makefile b/bin/test/tests/Makefile index 5ee337a..a1a5d4f 100644 --- a/bin/test/tests/Makefile +++ b/bin/test/tests/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/bin/test - TAP_TESTS_SH= legacy_test # Some tests in here are silently not run when the tests are executed as # root. Explicitly tell Kyua to drop privileges. diff --git a/bin/tests/Makefile b/bin/tests/Makefile index 7a59b10..a0e63e5 100644 --- a/bin/tests/Makefile +++ b/bin/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/bin - -.PATH: ${.CURDIR:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/cddl/lib/tests/Makefile b/cddl/lib/tests/Makefile index 4a49d9f..a0e63e5 100644 --- a/cddl/lib/tests/Makefile +++ b/cddl/lib/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/cddl/lib - -.PATH: ${.CURDIR:H:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/cddl/sbin/tests/Makefile b/cddl/sbin/tests/Makefile index 91bbaee..a0e63e5 100644 --- a/cddl/sbin/tests/Makefile +++ b/cddl/sbin/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/cddl/sbin - -.PATH: ${.CURDIR:H:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/cddl/tests/Makefile b/cddl/tests/Makefile index 34a27ea..a0e63e5 100644 --- a/cddl/tests/Makefile +++ b/cddl/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/cddl - -.PATH: ${.CURDIR:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/cddl/usr.bin/tests/Makefile b/cddl/usr.bin/tests/Makefile index c94d591..a0e63e5 100644 --- a/cddl/usr.bin/tests/Makefile +++ b/cddl/usr.bin/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/cddl/usr.bin - -.PATH: ${.CURDIR:H:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/cddl/usr.sbin/dtrace/tests/Makefile b/cddl/usr.sbin/dtrace/tests/Makefile index dfd2b54..7db6f2f 100644 --- a/cddl/usr.sbin/dtrace/tests/Makefile +++ b/cddl/usr.sbin/dtrace/tests/Makefile @@ -2,10 +2,9 @@ .include -TESTSDIR= ${TESTSBASE}/cddl/usr.sbin/dtrace TESTS_SUBDIRS+= common -.PATH: ${.CURDIR:H:H:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= YES .PATH: ${.CURDIR}/tools diff --git a/cddl/usr.sbin/tests/Makefile b/cddl/usr.sbin/tests/Makefile index 0305aee..a0e63e5 100644 --- a/cddl/usr.sbin/tests/Makefile +++ b/cddl/usr.sbin/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/cddl/usr.sbin - -.PATH: ${.CURDIR:H:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/gnu/lib/tests/Makefile b/gnu/lib/tests/Makefile index 256e245..a0e63e5 100644 --- a/gnu/lib/tests/Makefile +++ b/gnu/lib/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/gnu/lib - -.PATH: ${.CURDIR:H:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/gnu/tests/Makefile b/gnu/tests/Makefile index de42fae..a0e63e5 100644 --- a/gnu/tests/Makefile +++ b/gnu/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/gnu - -.PATH: ${.CURDIR:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/gnu/usr.bin/diff/tests/Makefile b/gnu/usr.bin/diff/tests/Makefile index aa1629d..16439b3 100644 --- a/gnu/usr.bin/diff/tests/Makefile +++ b/gnu/usr.bin/diff/tests/Makefile @@ -1,17 +1,14 @@ # $FreeBSD$ -TESTSRC= ${.CURDIR}/../../../../contrib/netbsd-tests/usr.bin/diff -.PATH: ${TESTSRC} +TESTSRC= ${SRCTOP}/contrib/netbsd-tests/usr.bin/diff -.include - -TESTSDIR= ${TESTSBASE}/gnu/usr.bin/diff -ATF_TESTS_SH= diff_test +NETBSD_ATF_TESTS_SH= diff_test ATF_TESTS_SH_SED_diff_test= -e 's/t_diff/`basename $$0`/g' -ATF_TESTS_SH_SRC_diff_test= t_diff.sh FILESDIR= ${TESTSDIR} FILES+= d_mallocv1.in FILES+= d_mallocv2.in +.include + .include diff --git a/gnu/usr.bin/tests/Makefile b/gnu/usr.bin/tests/Makefile index eebbff6..a0e63e5 100644 --- a/gnu/usr.bin/tests/Makefile +++ b/gnu/usr.bin/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/gnu/usr.bin - -.PATH: ${.CURDIR:H:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/lib/atf/libatf-c++/tests/Makefile b/lib/atf/libatf-c++/tests/Makefile index 5f5a575..a069bb1 100644 --- a/lib/atf/libatf-c++/tests/Makefile +++ b/lib/atf/libatf-c++/tests/Makefile @@ -2,10 +2,9 @@ .include -TESTSDIR= ${TESTSBASE}/lib/atf/libatf-c++ TESTS_SUBDIRS= detail -ATF= ${.CURDIR:H:H:H:H}/contrib/atf +ATF= ${SRCTOP}/contrib/atf .PATH: ${ATF}/atf-c++ .PATH: ${ATF}/atf-c++/detail diff --git a/lib/atf/libatf-c++/tests/detail/Makefile b/lib/atf/libatf-c++/tests/detail/Makefile index 69c3e7b..f7d672e 100644 --- a/lib/atf/libatf-c++/tests/detail/Makefile +++ b/lib/atf/libatf-c++/tests/detail/Makefile @@ -4,7 +4,7 @@ TESTSDIR= ${TESTSBASE}/lib/atf/libatf-c++/detail -ATF= ${.CURDIR:H:H:H:H:H}/contrib/atf +ATF= ${SRCTOP}/contrib/atf .PATH: ${ATF}/atf-c++/detail CFLAGS+= -DATF_C_TESTS_BASE='"${TESTSBASE}/lib/atf/libatf-c"' diff --git a/lib/atf/libatf-c/tests/Makefile b/lib/atf/libatf-c/tests/Makefile index d5b6dc0..e864c2e 100644 --- a/lib/atf/libatf-c/tests/Makefile +++ b/lib/atf/libatf-c/tests/Makefile @@ -2,10 +2,9 @@ .include -TESTSDIR= ${TESTSBASE}/lib/atf/libatf-c TESTS_SUBDIRS= detail -ATF= ${.CURDIR:H:H:H:H}/contrib/atf +ATF= ${SRCTOP}/contrib/atf .PATH: ${ATF}/atf-c .PATH: ${ATF}/atf-c/detail diff --git a/lib/atf/libatf-c/tests/detail/Makefile b/lib/atf/libatf-c/tests/detail/Makefile index 02c1f2b..e47fd56 100644 --- a/lib/atf/libatf-c/tests/detail/Makefile +++ b/lib/atf/libatf-c/tests/detail/Makefile @@ -4,7 +4,7 @@ TESTSDIR= ${TESTSBASE}/lib/atf/libatf-c/detail -ATF= ${.CURDIR:H:H:H:H:H}/contrib/atf +ATF= ${SRCTOP}/contrib/atf .PATH: ${ATF}/atf-c/detail CFLAGS+= -DATF_INCLUDEDIR='"${INCLUDEDIR}"' diff --git a/lib/atf/tests/Makefile b/lib/atf/tests/Makefile index 7bc96c9..dc79bb3 100644 --- a/lib/atf/tests/Makefile +++ b/lib/atf/tests/Makefile @@ -4,7 +4,7 @@ TESTSDIR= ${TESTSBASE}/lib/atf -.PATH: ${.CURDIR:H:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes SUBDIR= test-programs diff --git a/lib/atf/tests/test-programs/Makefile b/lib/atf/tests/test-programs/Makefile index b0c1c23..aa30826 100644 --- a/lib/atf/tests/test-programs/Makefile +++ b/lib/atf/tests/test-programs/Makefile @@ -5,7 +5,7 @@ TESTSDIR= ${TESTSBASE}/lib/atf/test-programs KYUAFILE= yes -ATF= ${.CURDIR:H:H:H:H}/contrib/atf +ATF= ${SRCTOP}/contrib/atf .PATH: ${ATF}/test-programs CFLAGS+= -I${ATF} diff --git a/lib/libc/tests/Makefile b/lib/libc/tests/Makefile index 9b89152..677f697 100644 --- a/lib/libc/tests/Makefile +++ b/lib/libc/tests/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc - SUBDIR= tls_dso TESTS_SUBDIRS= c063 diff --git a/lib/libc/tests/Makefile.netbsd-tests b/lib/libc/tests/Makefile.netbsd-tests index 56472fb..18b0276 100644 --- a/lib/libc/tests/Makefile.netbsd-tests +++ b/lib/libc/tests/Makefile.netbsd-tests @@ -1,8 +1,8 @@ # $FreeBSD$ -OBJTOP?= ${.OBJDIR:H:H:H:H} -SRCTOP?= ${.CURDIR:H:H:H:H} -TESTSRC?= ${SRCTOP}/contrib/netbsd-tests/lib/libc/${.CURDIR:T} +TESTSRC:= ${SRCTOP}/contrib/netbsd-tests/${RELDIR:C/libc\/tests/libc/} + +TESTSDIR:= ${TESTSBASE}/${RELDIR:C/libc\/tests/libc/} WARNS?= 2 diff --git a/lib/libc/tests/c063/Makefile b/lib/libc/tests/c063/Makefile index 27c44dc..c890eda 100644 --- a/lib/libc/tests/c063/Makefile +++ b/lib/libc/tests/c063/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/c063 - #TODO: t_o_search NETBSD_ATF_TESTS_C= faccessat_test diff --git a/lib/libc/tests/db/Makefile b/lib/libc/tests/db/Makefile index ed1d6ca..eb0ce39 100644 --- a/lib/libc/tests/db/Makefile +++ b/lib/libc/tests/db/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/db - BINDIR= ${TESTSDIR} PROGS= h_db diff --git a/lib/libc/tests/gen/Makefile b/lib/libc/tests/gen/Makefile index 91097ef..476b5b7 100644 --- a/lib/libc/tests/gen/Makefile +++ b/lib/libc/tests/gen/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/gen - ATF_TESTS_C+= arc4random_test ATF_TESTS_C+= fmtcheck2_test ATF_TESTS_C+= fmtmsg_test diff --git a/lib/libc/tests/gen/execve/Makefile b/lib/libc/tests/gen/execve/Makefile index 2106a15..5e8bc6f 100644 --- a/lib/libc/tests/gen/execve/Makefile +++ b/lib/libc/tests/gen/execve/Makefile @@ -1,13 +1,7 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR:H:H:H:H:H} -SRCTOP= ${.CURDIR:H:H:H:H:H} -TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/gen/${.CURDIR:T} - .include -TESTSDIR= ${TESTSBASE}/lib/libc/gen/execve - NETBSD_ATF_TESTS_C= execve_test .include "../../Makefile.netbsd-tests" diff --git a/lib/libc/tests/gen/posix_spawn/Makefile b/lib/libc/tests/gen/posix_spawn/Makefile index f20bbd7..9bb2cf1 100644 --- a/lib/libc/tests/gen/posix_spawn/Makefile +++ b/lib/libc/tests/gen/posix_spawn/Makefile @@ -1,13 +1,7 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR:H:H:H:H:H} -SRCTOP= ${.CURDIR:H:H:H:H:H} -TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/gen/${.CURDIR:T} - .include -TESTSDIR= ${TESTSBASE}/lib/libc/gen/posix_spawn - BINDIR= ${TESTSDIR} NETBSD_ATF_TESTS_C= fileactions_test diff --git a/lib/libc/tests/hash/Makefile b/lib/libc/tests/hash/Makefile index 4c64c70..1a71eaa 100644 --- a/lib/libc/tests/hash/Makefile +++ b/lib/libc/tests/hash/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/hash - NETBSD_ATF_TESTS_C= .if ${MK_OPENSSL} != "no" @@ -29,8 +27,8 @@ LDADD+= -lmd DPADD.sha2_test+= ${LIBCRYPTO} LDADD.sha2_test+= -lcrypto -CFLAGS.sha2_test+= -I${.CURDIR}/../../../../crypto/openssh/openbsd-compat -CFLAGS.sha2_test+= -I${.CURDIR}/../../../../crypto/openssh +CFLAGS.sha2_test+= -I${SRCTOP}/crypto/openssh/openbsd-compat +CFLAGS.sha2_test+= -I${SRCTOP}/crypto/openssh .include "../Makefile.netbsd-tests" diff --git a/lib/libc/tests/inet/Makefile b/lib/libc/tests/inet/Makefile index a15b96a..ee6f98e 100644 --- a/lib/libc/tests/inet/Makefile +++ b/lib/libc/tests/inet/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/inet - NETBSD_ATF_TESTS_C= inet_network_test .include "../Makefile.netbsd-tests" diff --git a/lib/libc/tests/locale/Makefile b/lib/libc/tests/locale/Makefile index d15fd5e..e05cbae 100644 --- a/lib/libc/tests/locale/Makefile +++ b/lib/libc/tests/locale/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/locale - ATF_TESTS_C+= btowc_test ATF_TESTS_C+= c16rtomb_test ATF_TESTS_C+= iswctype_test diff --git a/lib/libc/tests/net/Makefile b/lib/libc/tests/net/Makefile index fb76f26..bee179f 100644 --- a/lib/libc/tests/net/Makefile +++ b/lib/libc/tests/net/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/net - ATF_TESTS_C+= ether_test ATF_TESTS_C+= eui64_aton_test ATF_TESTS_C+= eui64_ntoa_test diff --git a/lib/libc/tests/net/getaddrinfo/Makefile b/lib/libc/tests/net/getaddrinfo/Makefile index a6b9eb1..d21d336 100644 --- a/lib/libc/tests/net/getaddrinfo/Makefile +++ b/lib/libc/tests/net/getaddrinfo/Makefile @@ -1,13 +1,9 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR:H:H:H:H:H} -SRCTOP= ${.CURDIR:H:H:H:H:H} TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/net/${.CURDIR:T} .include -TESTSDIR= ${TESTSBASE}/lib/libc/net/getaddrinfo - BINDIR= ${TESTSDIR} .error "This testcase needs to be ported to FreeBSD (the output from getaddrinfo_test differs from NetBSD)" diff --git a/lib/libc/tests/regex/Makefile b/lib/libc/tests/regex/Makefile index 37b3277..fa60f6e 100644 --- a/lib/libc/tests/regex/Makefile +++ b/lib/libc/tests/regex/Makefile @@ -4,8 +4,6 @@ BINDIR= ${TESTSDIR} -TESTSDIR= ${TESTSBASE}/lib/libc/regex - IMPLEMENTATION?= -DREGEX_SPENCER CFLAGS.h_regex+=-I${TESTSRC} -I${.CURDIR:H:H}/regex diff --git a/lib/libc/tests/rpc/Makefile b/lib/libc/tests/rpc/Makefile index 153626b..f9819d3 100644 --- a/lib/libc/tests/rpc/Makefile +++ b/lib/libc/tests/rpc/Makefile @@ -1,6 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/rpc SRCS.xdr_test= ${RPCSRC:.x=_xdr.c} t_xdr.c ${RPCSRC:.x=.h} \ h_testbits.h diff --git a/lib/libc/tests/setjmp/Makefile b/lib/libc/tests/setjmp/Makefile index e303726..ac962c2 100644 --- a/lib/libc/tests/setjmp/Makefile +++ b/lib/libc/tests/setjmp/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/setjmp - NETBSD_ATF_TESTS_C= setjmp_test NETBSD_ATF_TESTS_C+= threadjmp_test @@ -10,4 +8,6 @@ LDADD.threadjmp_test+= -lpthread WARNS?= 4 +.include "../Makefile.netbsd-tests" + .include diff --git a/lib/libc/tests/ssp/Makefile b/lib/libc/tests/ssp/Makefile index 7bc8660..ec7a82a 100644 --- a/lib/libc/tests/ssp/Makefile +++ b/lib/libc/tests/ssp/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/ssp - NO_WERROR= WARNS?= 2 diff --git a/lib/libc/tests/stdio/Makefile b/lib/libc/tests/stdio/Makefile index 06ceb46..7896422 100644 --- a/lib/libc/tests/stdio/Makefile +++ b/lib/libc/tests/stdio/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/stdio - ATF_TESTS_C+= fdopen_test ATF_TESTS_C+= fmemopen2_test ATF_TESTS_C+= fopen2_test diff --git a/lib/libc/tests/stdlib/Makefile b/lib/libc/tests/stdlib/Makefile index 15d8cbc..99d17e2 100644 --- a/lib/libc/tests/stdlib/Makefile +++ b/lib/libc/tests/stdlib/Makefile @@ -10,8 +10,6 @@ ATF_TESTS_CXX+= cxa_thread_atexit_test ATF_TESTS_CXX+= cxa_thread_atexit_nothr_test .endif -TESTSDIR= ${TESTSBASE}/lib/libc/stdlib - # TODO: t_getenv_thread, t_mi_vector_hash NETBSD_ATF_TESTS_C+= abs_test NETBSD_ATF_TESTS_C+= atoi_test diff --git a/lib/libc/tests/string/Makefile b/lib/libc/tests/string/Makefile index 3f97edc..14044f4 100644 --- a/lib/libc/tests/string/Makefile +++ b/lib/libc/tests/string/Makefile @@ -5,8 +5,6 @@ ATF_TESTS_C+= strerror2_test ATF_TESTS_C+= wcscasecmp_test ATF_TESTS_C+= wcsnlen_test -TESTSDIR= ${TESTSBASE}/lib/libc/string - # TODO: popcount, stresep NETBSD_ATF_TESTS_C+= memchr_test diff --git a/lib/libc/tests/sys/Makefile b/lib/libc/tests/sys/Makefile index 39aec1f..816b962 100644 --- a/lib/libc/tests/sys/Makefile +++ b/lib/libc/tests/sys/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/sys - ATF_TESTS_C+= queue_test # TODO: clone, lwp_create, lwp_ctl, posix_fadvise, recvmmsg, diff --git a/lib/libc/tests/termios/Makefile b/lib/libc/tests/termios/Makefile index 9a3fd66..0495d68 100644 --- a/lib/libc/tests/termios/Makefile +++ b/lib/libc/tests/termios/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/termios - NETBSD_ATF_TESTS_C= tcsetpgrp_test .include "../Makefile.netbsd-tests" diff --git a/lib/libc/tests/time/Makefile b/lib/libc/tests/time/Makefile index c2a55df..feb543d 100644 --- a/lib/libc/tests/time/Makefile +++ b/lib/libc/tests/time/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/time - NETBSD_ATF_TESTS_C= mktime_test NETBSD_ATF_TESTS_C+= strptime_test diff --git a/lib/libc/tests/tls/Makefile b/lib/libc/tests/tls/Makefile index e224895..b6b6719 100644 --- a/lib/libc/tests/tls/Makefile +++ b/lib/libc/tests/tls/Makefile @@ -2,7 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/tls .if !defined(NO_PIC) SUBDIR+= dso .endif diff --git a/lib/libc/tests/tls/dso/Makefile b/lib/libc/tests/tls/dso/Makefile index 466f950..9b698cd 100644 --- a/lib/libc/tests/tls/dso/Makefile +++ b/lib/libc/tests/tls/dso/Makefile @@ -1,7 +1,6 @@ # $FreeBSD$ OBJTOP= ${.OBJDIR:H:H:H:H:H} -SRCTOP= ${.CURDIR:H:H:H:H:H} TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/tls/${.CURDIR:T} LIB= h_tls_dlopen diff --git a/lib/libc/tests/ttyio/Makefile b/lib/libc/tests/ttyio/Makefile index a1f320d..242f332 100644 --- a/lib/libc/tests/ttyio/Makefile +++ b/lib/libc/tests/ttyio/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/ttyio - # TODO: ptm_test NETBSD_ATF_TESTS_C= ttyio_test diff --git a/lib/libcrypt/tests/Makefile b/lib/libcrypt/tests/Makefile index 65ebd66..8e3fc2e 100644 --- a/lib/libcrypt/tests/Makefile +++ b/lib/libcrypt/tests/Makefile @@ -4,8 +4,6 @@ SRCTOP= ${.CURDIR:H:H:H} OBJTOP= ${.OBJDIR:H:H:H} TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libcrypt -TESTSDIR= ${TESTSBASE}/lib/libcrypt - NETBSD_ATF_TESTS_C+= crypt_test CFLAGS+= -I${.CURDIR:H} diff --git a/lib/libmp/tests/Makefile b/lib/libmp/tests/Makefile index 0f591eb..d556347 100644 --- a/lib/libmp/tests/Makefile +++ b/lib/libmp/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libmp - TAP_TESTS_C+= legacy_test DPADD+= ${LIBCRYPTO} ${LIBMP} diff --git a/lib/libnv/tests/Makefile b/lib/libnv/tests/Makefile index d8e0904..870b7df 100644 --- a/lib/libnv/tests/Makefile +++ b/lib/libnv/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libnv - ATF_TESTS_CXX= \ dnv_tests \ nv_tests \ diff --git a/lib/libpam/libpam/tests/Makefile b/lib/libpam/libpam/tests/Makefile index 2ad64e2..a581392 100644 --- a/lib/libpam/libpam/tests/Makefile +++ b/lib/libpam/libpam/tests/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -OPENPAM = ${.CURDIR}/../../../../contrib/openpam +OPENPAM= ${SRCTOP}/contrib/openpam .PATH: ${OPENPAM}/t TESTSDIR = ${TESTSBASE}/lib/libpam diff --git a/lib/librt/tests/Makefile b/lib/librt/tests/Makefile index 224f52e..3d3f98c 100644 --- a/lib/librt/tests/Makefile +++ b/lib/librt/tests/Makefile @@ -1,11 +1,5 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR:H:H:H} -SRCTOP= ${.CURDIR:H:H:H} -TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/librt - -TESTSDIR= ${TESTSBASE}/lib/librt - DPADD+= ${LIBRT} LDADD+= -lrt diff --git a/lib/libthr/tests/Makefile b/lib/libthr/tests/Makefile index 50f07f0..b0725dc 100644 --- a/lib/libthr/tests/Makefile +++ b/lib/libthr/tests/Makefile @@ -1,11 +1,7 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR:H:H:H} -SRCTOP= ${.CURDIR:H:H:H} TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libpthread -TESTSDIR= ${TESTSBASE}/lib/libthr - # TODO: t_name (missing pthread_getname_np support in FreeBSD) NETBSD_ATF_TESTS_C= barrier_test NETBSD_ATF_TESTS_C+= cond_test diff --git a/lib/libthr/tests/dlopen/Makefile b/lib/libthr/tests/dlopen/Makefile index 0764bfa..0893192 100644 --- a/lib/libthr/tests/dlopen/Makefile +++ b/lib/libthr/tests/dlopen/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR:H:H:H:H} -SRCTOP= ${.CURDIR:H:H:H:H} TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libpthread/dlopen .include diff --git a/lib/libthr/tests/dlopen/dso/Makefile b/lib/libthr/tests/dlopen/dso/Makefile index 080dec9..dce7d38 100644 --- a/lib/libthr/tests/dlopen/dso/Makefile +++ b/lib/libthr/tests/dlopen/dso/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR:H:H:H:H:H} -SRCTOP= ${.CURDIR:H:H:H:H:H} TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libpthread/dlopen/dso SHLIB= h_pthread_dlopen diff --git a/lib/libutil/tests/Makefile b/lib/libutil/tests/Makefile index 31b6c54..92540c9 100644 --- a/lib/libutil/tests/Makefile +++ b/lib/libutil/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libutil - TAP_TESTS_C+= flopen_test TAP_TESTS_C+= grp_test TAP_TESTS_C+= humanize_number_test diff --git a/lib/msun/tests/Makefile b/lib/msun/tests/Makefile index a82f29f..e96426b 100644 --- a/lib/msun/tests/Makefile +++ b/lib/msun/tests/Makefile @@ -1,11 +1,7 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR:H:H:H} -SRCTOP= ${.CURDIR:H:H:H} TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libm -TESTSDIR= ${TESTSBASE}/lib/msun - # All architectures on FreeBSD have fenv.h CFLAGS+= -DHAVE_FENV_H diff --git a/lib/tests/Makefile b/lib/tests/Makefile index 935fd70..a0e63e5 100644 --- a/lib/tests/Makefile +++ b/lib/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/lib - -.PATH: ${.CURDIR:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/libexec/atf/atf-check/tests/Makefile b/libexec/atf/atf-check/tests/Makefile index 43a7498..87b26cb 100644 --- a/libexec/atf/atf-check/tests/Makefile +++ b/libexec/atf/atf-check/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/libexec/atf/atf-check - -ATF= ${.CURDIR:H:H:H:H}/contrib/atf +ATF= ${SRCTOP}/contrib/atf .PATH: ${ATF}/atf-sh ATF_TESTS_SH= atf-check_test diff --git a/libexec/atf/atf-sh/tests/Makefile b/libexec/atf/atf-sh/tests/Makefile index 3360b97..9ccd6a7 100644 --- a/libexec/atf/atf-sh/tests/Makefile +++ b/libexec/atf/atf-sh/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/libexec/atf/atf-sh - -ATF= ${.CURDIR:H:H:H:H}/contrib/atf +ATF= ${SRCTOP}/contrib/atf .PATH: ${ATF}/atf-sh ATF_TESTS_SH+= atf_check_test diff --git a/libexec/atf/tests/Makefile b/libexec/atf/tests/Makefile index 7aa9601..a0e63e5 100644 --- a/libexec/atf/tests/Makefile +++ b/libexec/atf/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/libexec/atf - -.PATH: ${.CURDIR:H:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/libexec/tests/Makefile b/libexec/tests/Makefile index 665efab..a0e63e5 100644 --- a/libexec/tests/Makefile +++ b/libexec/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/libexec - -.PATH: ${.CURDIR:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/sbin/devd/tests/Makefile b/sbin/devd/tests/Makefile index ee679ce..e06928c 100644 --- a/sbin/devd/tests/Makefile +++ b/sbin/devd/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/sbin/devd - ATF_TESTS_C= client_test TEST_METADATA.client_test= required_programs="devd" TEST_METADATA.client_test+= required_user="root" diff --git a/sbin/dhclient/tests/Makefile b/sbin/dhclient/tests/Makefile index a460f7f..45cc8c2 100644 --- a/sbin/dhclient/tests/Makefile +++ b/sbin/dhclient/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/sbin/dhclient - .PATH: ${.CURDIR}/.. PLAIN_TESTS_C= option-domain-search_test diff --git a/sbin/growfs/tests/Makefile b/sbin/growfs/tests/Makefile index 7a6a831..6a3208d 100644 --- a/sbin/growfs/tests/Makefile +++ b/sbin/growfs/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/sbin/growfs - TAP_TESTS_PERL= legacy_test .include diff --git a/sbin/mdconfig/tests/Makefile b/sbin/mdconfig/tests/Makefile index 08a9e47..6c179fc 100644 --- a/sbin/mdconfig/tests/Makefile +++ b/sbin/mdconfig/tests/Makefile @@ -1,10 +1,7 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/sbin/mdconfig - ATF_TESTS_SH= mdconfig_test - TEST_METADATA.mdconfig_test+= required_user="root" .include diff --git a/sbin/tests/Makefile b/sbin/tests/Makefile index a298f87..a0e63e5 100644 --- a/sbin/tests/Makefile +++ b/sbin/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/sbin - -.PATH: ${.CURDIR:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/secure/lib/tests/Makefile b/secure/lib/tests/Makefile index cd6bcff..a0e63e5 100644 --- a/secure/lib/tests/Makefile +++ b/secure/lib/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/secure/lib - -.PATH: ${.CURDIR:H:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/secure/libexec/tests/Makefile b/secure/libexec/tests/Makefile index 6debef8..a0e63e5 100644 --- a/secure/libexec/tests/Makefile +++ b/secure/libexec/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/secure/libexec - -.PATH: ${.CURDIR:H:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/secure/tests/Makefile b/secure/tests/Makefile index 2e6dbc4..a0e63e5 100644 --- a/secure/tests/Makefile +++ b/secure/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/secure - -.PATH: ${.CURDIR:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/secure/usr.bin/tests/Makefile b/secure/usr.bin/tests/Makefile index 1c06699..a0e63e5 100644 --- a/secure/usr.bin/tests/Makefile +++ b/secure/usr.bin/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/secure/usr.bin - -.PATH: ${.CURDIR:H:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/secure/usr.sbin/tests/Makefile b/secure/usr.sbin/tests/Makefile index 25e95f0..a0e63e5 100644 --- a/secure/usr.sbin/tests/Makefile +++ b/secure/usr.sbin/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/secure/usr.sbin - -.PATH: ${.CURDIR:H:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/share/examples/tests/Makefile b/share/examples/tests/Makefile index 387b806..a091b2d 100644 --- a/share/examples/tests/Makefile +++ b/share/examples/tests/Makefile @@ -2,11 +2,9 @@ .include -TESTSDIR= ${TESTSBASE}/share/examples - SUBDIR= tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes -.PATH: ${.CURDIR:H:H:H}/tests .include diff --git a/share/tests/Makefile b/share/tests/Makefile index 2c63621..e070571 100644 --- a/share/tests/Makefile +++ b/share/tests/Makefile @@ -4,7 +4,7 @@ TESTSDIR= ${TESTSBASE}/share -.PATH: ${.CURDIR:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include diff --git a/tests/etc/Makefile b/tests/etc/Makefile index 9aad25c..1e49666 100644 --- a/tests/etc/Makefile +++ b/tests/etc/Makefile @@ -4,7 +4,7 @@ TESTSDIR= ${TESTSBASE}/etc -.PATH: ${.CURDIR:H} +.PATH: ${SRCTOP}/tests KYUAFILE= yes SUBDIR+= rc.d diff --git a/tests/sys/mqueue/Makefile b/tests/sys/mqueue/Makefile index 5af8b25..63741d2 100644 --- a/tests/sys/mqueue/Makefile +++ b/tests/sys/mqueue/Makefile @@ -6,7 +6,7 @@ ATF_TESTS_SH= mqueue_test BINDIR= ${TESTSDIR} -CFLAGS+= -I${.CURDIR:H:H} +CFLAGS+= -I${SRCTOP}/tests PROGS+= mqtest1 PROGS+= mqtest2 diff --git a/tests/sys/pjdfstest/tests/Makefile b/tests/sys/pjdfstest/tests/Makefile index 917b01a..61b15dd 100644 --- a/tests/sys/pjdfstest/tests/Makefile +++ b/tests/sys/pjdfstest/tests/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -PJDFSTEST_SRCDIR= ${.CURDIR:H:H:H:H}/contrib/pjdfstest +PJDFSTEST_SRCDIR= ${SRCTOP}/contrib/pjdfstest TESTSDIR= ${TESTSBASE}/sys/pjdfstest diff --git a/usr.bin/apply/tests/Makefile b/usr.bin/apply/tests/Makefile index 332bf7d..5ff6c28 100644 --- a/usr.bin/apply/tests/Makefile +++ b/usr.bin/apply/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/apply - TAP_TESTS_SH= legacy_test FILESDIR= ${TESTSDIR} diff --git a/usr.bin/basename/tests/Makefile b/usr.bin/basename/tests/Makefile index 32dedab..bad7b28 100644 --- a/usr.bin/basename/tests/Makefile +++ b/usr.bin/basename/tests/Makefile @@ -1,12 +1,7 @@ # $FreeBSD$ -TESTSRC= ${.CURDIR}/../../../contrib/netbsd-tests/usr.bin/basename -.PATH: ${TESTSRC} +NETBSD_ATF_TESTS_SH= basename_test -.include - -TESTSDIR= ${TESTSBASE}/usr.bin/basename -ATF_TESTS_SH= basename_test -ATF_TESTS_SH_SRC_basename_test= t_basename.sh +.include .include diff --git a/usr.bin/calendar/tests/Makefile b/usr.bin/calendar/tests/Makefile index f3d592e..b9b0607 100644 --- a/usr.bin/calendar/tests/Makefile +++ b/usr.bin/calendar/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/calendar - TAP_TESTS_SH= legacy_test FILESDIR= ${TESTSDIR} diff --git a/usr.bin/cmp/tests/Makefile b/usr.bin/cmp/tests/Makefile index 1c054c6..bfae46c 100644 --- a/usr.bin/cmp/tests/Makefile +++ b/usr.bin/cmp/tests/Makefile @@ -1,12 +1,9 @@ # $FreeBSD$ -TESTSRC= ${.CURDIR}/../../../contrib/netbsd-tests/usr.bin/cmp -.PATH: ${TESTSRC} - .include -TESTSDIR= ${TESTSBASE}/usr.bin/cmp -ATF_TESTS_SH= cmp_test -ATF_TESTS_SH_SRC_cmp_test= t_cmp.sh +NETBSD_ATF_TESTS_SH= cmp_test + +.include .include diff --git a/usr.bin/col/tests/Makefile b/usr.bin/col/tests/Makefile index 43838e9..cf02083 100644 --- a/usr.bin/col/tests/Makefile +++ b/usr.bin/col/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/col - ATF_TESTS_SH= col FILES= rlf.in \ diff --git a/usr.bin/comm/tests/Makefile b/usr.bin/comm/tests/Makefile index 172943d..065b3b4 100644 --- a/usr.bin/comm/tests/Makefile +++ b/usr.bin/comm/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/comm - TAP_TESTS_SH= legacy_test FILESDIR= ${TESTSDIR} diff --git a/usr.bin/cut/tests/Makefile b/usr.bin/cut/tests/Makefile index b324a78..7d8707d 100644 --- a/usr.bin/cut/tests/Makefile +++ b/usr.bin/cut/tests/Makefile @@ -1,13 +1,8 @@ # $FreeBSD$ -TESTSRC= ${.CURDIR}/../../../contrib/netbsd-tests/usr.bin/cut -.PATH: ${TESTSRC} - .include -TESTSDIR= ${TESTSBASE}/usr.bin/cut -ATF_TESTS_SH= cut_test -ATF_TESTS_SH_SRC_cut_test= t_cut.sh +NETBSD_ATF_TESTS_SH= cut_test FILESDIR= ${TESTSDIR} FILES= d_basic.out @@ -18,4 +13,6 @@ FILES+= d_latin1.in FILES+= d_sflag.out FILES+= d_utf8.in +.include + .include diff --git a/usr.bin/dirname/tests/Makefile b/usr.bin/dirname/tests/Makefile index 5b84c57..6688e0d 100644 --- a/usr.bin/dirname/tests/Makefile +++ b/usr.bin/dirname/tests/Makefile @@ -1,12 +1,9 @@ # $FreeBSD$ -TESTSRC= ${.CURDIR}/../../../contrib/netbsd-tests/usr.bin/dirname -.PATH: ${TESTSRC} - .include -TESTSDIR= ${TESTSBASE}/usr.bin/dirname -ATF_TESTS_SH= dirname_test -ATF_TESTS_SH_SRC_dirname_test= t_dirname.sh +NETBSD_ATF_TESTS_SH= dirname_test + +.include .include diff --git a/usr.bin/file2c/tests/Makefile b/usr.bin/file2c/tests/Makefile index 8854eb4..50267f0 100644 --- a/usr.bin/file2c/tests/Makefile +++ b/usr.bin/file2c/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/file2c - TAP_TESTS_SH= legacy_test FILESDIR= ${TESTSDIR} diff --git a/usr.bin/grep/tests/Makefile b/usr.bin/grep/tests/Makefile index 59b948c..7744fcb 100644 --- a/usr.bin/grep/tests/Makefile +++ b/usr.bin/grep/tests/Makefile @@ -1,14 +1,8 @@ # $FreeBSD$ -TESTSRC= ${.CURDIR}/../../../contrib/netbsd-tests/usr.bin/grep -.PATH: ${TESTSRC} - .include -TESTSDIR= ${TESTSBASE}/usr.bin/grep - -ATF_TESTS_SH= grep_test -ATF_TESTS_SH_SRC_grep_test= t_grep.sh +NETBSD_ATF_TESTS_SH= grep_test FILESDIR= ${TESTSDIR} FILES= d_basic.out @@ -38,4 +32,6 @@ FILES+= d_whole_line.out FILES+= d_word_regexps.out FILES+= d_zgrep.out +.include + .include diff --git a/usr.bin/gzip/tests/Makefile b/usr.bin/gzip/tests/Makefile index 155d739..03a5852 100644 --- a/usr.bin/gzip/tests/Makefile +++ b/usr.bin/gzip/tests/Makefile @@ -1,12 +1,9 @@ # $FreeBSD$ -TESTSRC= ${.CURDIR}/../../../contrib/netbsd-tests/usr.bin/gzip -.PATH: ${TESTSRC} - .include -TESTSDIR= ${TESTSBASE}/usr.bin/gzip -ATF_TESTS_SH= gzip_test -ATF_TESTS_SH_SRC_gzip_test= t_gzip.sh +NETBSD_ATF_TESTS_SH= gzip_test + +.include .include diff --git a/usr.bin/join/tests/Makefile b/usr.bin/join/tests/Makefile index 2d5580f..16f522f 100644 --- a/usr.bin/join/tests/Makefile +++ b/usr.bin/join/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/join - TAP_TESTS_SH= legacy_test FILESDIR= ${TESTSDIR} diff --git a/usr.bin/jot/tests/Makefile b/usr.bin/jot/tests/Makefile index ef20eb2..63f7631 100644 --- a/usr.bin/jot/tests/Makefile +++ b/usr.bin/jot/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/jot - TAP_TESTS_SH= legacy_test FILESDIR= ${TESTSDIR} diff --git a/usr.bin/lastcomm/tests/Makefile b/usr.bin/lastcomm/tests/Makefile index d357648..71e8395 100644 --- a/usr.bin/lastcomm/tests/Makefile +++ b/usr.bin/lastcomm/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/lastcomm - TAP_TESTS_SH= legacy_test TEST_METADATA.legacy_test+= allowed_architectures="amd64 i386 sparc64" diff --git a/usr.bin/m4/tests/Makefile b/usr.bin/m4/tests/Makefile index 2eebc07..6a48677 100644 --- a/usr.bin/m4/tests/Makefile +++ b/usr.bin/m4/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/m4 - TAP_TESTS_SH= legacy_test FILESDIR= ${TESTSDIR} diff --git a/usr.bin/ncal/tests/Makefile b/usr.bin/ncal/tests/Makefile index 170caac..23b235f 100644 --- a/usr.bin/ncal/tests/Makefile +++ b/usr.bin/ncal/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/ncal - TAP_TESTS_SH= legacy_test FILESDIR= ${TESTSDIR} diff --git a/usr.bin/printf/tests/Makefile b/usr.bin/printf/tests/Makefile index da3f533..5ed5c00 100644 --- a/usr.bin/printf/tests/Makefile +++ b/usr.bin/printf/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/printf - TAP_TESTS_SH= legacy_test FILESDIR= ${TESTSDIR} diff --git a/usr.bin/sed/tests/Makefile b/usr.bin/sed/tests/Makefile index 02d2b89..a23d4a9 100644 --- a/usr.bin/sed/tests/Makefile +++ b/usr.bin/sed/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/sed - TAP_TESTS_SH= legacy_test TAP_TESTS_SH+= multi_test TEST_METADATA.multi_test+= required_files="/usr/share/dict/words" diff --git a/usr.bin/tests/Makefile b/usr.bin/tests/Makefile index af7a8bf..08b47bc 100644 --- a/usr.bin/tests/Makefile +++ b/usr.bin/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/usr.bin - -.PATH: ${.CURDIR:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes FILESDIR= ${TESTSDIR} diff --git a/usr.bin/truncate/tests/Makefile b/usr.bin/truncate/tests/Makefile index bfa15db..82cd606 100644 --- a/usr.bin/truncate/tests/Makefile +++ b/usr.bin/truncate/tests/Makefile @@ -1,6 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/truncate -ATF_TESTS_SH= truncate_test +ATF_TESTS_SH= truncate_test .include diff --git a/usr.bin/uudecode/tests/Makefile b/usr.bin/uudecode/tests/Makefile index 5fda16b..efd3f92 100644 --- a/usr.bin/uudecode/tests/Makefile +++ b/usr.bin/uudecode/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/uudecode - TAP_TESTS_SH= legacy_test FILESDIR= ${TESTSDIR} diff --git a/usr.bin/uuencode/tests/Makefile b/usr.bin/uuencode/tests/Makefile index ca7088e..a36ef6c 100644 --- a/usr.bin/uuencode/tests/Makefile +++ b/usr.bin/uuencode/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/uuencode - TAP_TESTS_SH= legacy_test FILESDIR= ${TESTSDIR} diff --git a/usr.bin/xargs/tests/Makefile b/usr.bin/xargs/tests/Makefile index cd14813..c8ef2c9 100644 --- a/usr.bin/xargs/tests/Makefile +++ b/usr.bin/xargs/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.bin/xargs - TAP_TESTS_SH= legacy_test FILESDIR= ${TESTSDIR} diff --git a/usr.bin/yacc/tests/Makefile b/usr.bin/yacc/tests/Makefile index 2e157ec..ad3abaa 100644 --- a/usr.bin/yacc/tests/Makefile +++ b/usr.bin/yacc/tests/Makefile @@ -2,12 +2,10 @@ .include -TEST_DIR= ${.CURDIR}/../../../contrib/byacc/test +TEST_DIR= ${SRCTOP}/contrib/byacc/test .PATH: ${TEST_DIR} ${TEST_DIR}/yacc -TESTSDIR= ${TESTSBASE}/usr.bin/yacc - PLAIN_TESTS_SH= yacc_tests # NOTE: due to caveats with how permissions are handled on FreeBSD # with root, this must be run as a non-privileged user; otherwise diff --git a/usr.sbin/etcupdate/tests/Makefile b/usr.sbin/etcupdate/tests/Makefile index da83397..45b12b7 100644 --- a/usr.sbin/etcupdate/tests/Makefile +++ b/usr.sbin/etcupdate/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.sbin/etcupdate - PLAIN_TESTS_SH= .for test in always_test \ conflicts_test \ diff --git a/usr.sbin/fstyp/tests/Makefile b/usr.sbin/fstyp/tests/Makefile index db686b59..01c9869 100644 --- a/usr.sbin/fstyp/tests/Makefile +++ b/usr.sbin/fstyp/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.sbin/fstyp - ATF_TESTS_SH= fstyp_test FILES= ext2.img.bz2 diff --git a/usr.sbin/newsyslog/tests/Makefile b/usr.sbin/newsyslog/tests/Makefile index f8ad273..802a44c 100644 --- a/usr.sbin/newsyslog/tests/Makefile +++ b/usr.sbin/newsyslog/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.sbin/newsyslog - TAP_TESTS_SH= legacy_test .include diff --git a/usr.sbin/nmtree/tests/Makefile b/usr.sbin/nmtree/tests/Makefile index 1df81d0..0b63127 100644 --- a/usr.sbin/nmtree/tests/Makefile +++ b/usr.sbin/nmtree/tests/Makefile @@ -1,10 +1,8 @@ # $FreeBSD$ -TESTSRC= ${.CURDIR}/../../../contrib/netbsd-tests/usr.sbin/mtree +TESTSRC= ${SRCTOP}/contrib/netbsd-tests/usr.sbin/mtree .PATH: ${TESTSRC} -TESTSDIR= ${TESTSBASE}/usr.sbin/nmtree - ATF_TESTS_SH= nmtree_test ATF_TESTS_SH_SRC_nmtree_test= t_mtree.sh diff --git a/usr.sbin/pw/tests/Makefile b/usr.sbin/pw/tests/Makefile index 07a8069..613d8b5 100644 --- a/usr.sbin/pw/tests/Makefile +++ b/usr.sbin/pw/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.sbin/pw - BINDIR= ${TESTSDIR} PROGS+= crypt diff --git a/usr.sbin/sa/tests/Makefile b/usr.sbin/sa/tests/Makefile index 2fdbbea..399d7d1 100644 --- a/usr.sbin/sa/tests/Makefile +++ b/usr.sbin/sa/tests/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/usr.sbin/sa - TAP_TESTS_SH= legacy_test TEST_METADATA.legacy_test+= allowed_architectures="amd64 i386 sparc64" diff --git a/usr.sbin/tests/Makefile b/usr.sbin/tests/Makefile index a7e9c71..a0e63e5 100644 --- a/usr.sbin/tests/Makefile +++ b/usr.sbin/tests/Makefile @@ -2,9 +2,7 @@ .include -TESTSDIR= ${TESTSBASE}/usr.sbin - -.PATH: ${.CURDIR:H:H}/tests +.PATH: ${SRCTOP}/tests KYUAFILE= yes .include -- cgit v1.1 From 9c6235cf2af8bdadcd0f0a80288683f0c88f3e55 Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 9 Feb 2017 22:57:56 +0000 Subject: MFC r296586: r296586 (by bdrewery): Fix and connect setjmp test. --- contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c | 2 +- contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c | 2 +- etc/mtree/BSD.tests.dist | 2 ++ lib/libc/tests/Makefile | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c b/contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c index 4d2a93b..34fd5cc 100644 --- a/contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c +++ b/contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c @@ -87,7 +87,7 @@ __RCSID("$NetBSD: t_setjmp.c,v 1.1 2010/12/27 19:35:31 pgoyette Exp $"); static int expectsignal; static void -aborthandler(int signo) +aborthandler(int signo __unused) { ATF_REQUIRE_MSG(expectsignal, "kill(SIGABRT) succeeded"); atf_tc_pass(); diff --git a/contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c b/contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c index 4437c92..2014470 100644 --- a/contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c +++ b/contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c @@ -91,7 +91,7 @@ static pthread_t myself = NULL; static int expectsignal; static void -aborthandler(int signo) +aborthandler(int signo __unused) { ATF_REQUIRE(myself == pthread_self()); ATF_REQUIRE_MSG(expectsignal, "kill(SIGABRT) succeeded"); diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index 8e0beeb..01b5362 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -285,6 +285,8 @@ .. ssp .. + setjmp + .. stdio .. stdlib diff --git a/lib/libc/tests/Makefile b/lib/libc/tests/Makefile index 677f697..3a7adc4 100644 --- a/lib/libc/tests/Makefile +++ b/lib/libc/tests/Makefile @@ -15,6 +15,7 @@ TESTS_SUBDIRS+= nss TESTS_SUBDIRS+= regex TESTS_SUBDIRS+= resolv TESTS_SUBDIRS+= rpc +TESTS_SUBDIRS+= setjmp TESTS_SUBDIRS+= stdio TESTS_SUBDIRS+= stdlib TESTS_SUBDIRS+= string -- cgit v1.1 From 8864cde3495dbfd6b476c1b77a8bde035e1cf000 Mon Sep 17 00:00:00 2001 From: ngie Date: Fri, 10 Feb 2017 01:13:12 +0000 Subject: MFC r305358,r305449,r305451,r306367,r306397,r309474: This also contains a merge of ^/projects/netbsd-tests-update-12@r304035 . This change never hit ^/head because bin/cat's behavior was changed (on ^/head) to match NetBSD. PR: 210607 r305358: Update contrib/netbsd-tests with new content from NetBSD This updates the snapshot from 09/30/2014 to 08/11/2016 This brings in a number of new testcases from upstream, most notably: - bin/cat - lib/libc - lib/msun - lib/libthr - usr.bin/sort lib/libc/tests/stdio/open_memstream_test.c was moved to lib/libc/tests/stdio/open_memstream2_test.c to accomodate the new open_memstream test from NetBSD. Tested on: amd64 (VMware fusion VM; various bare metal platforms); i386 (VMware fusion VM); make tinderbox r305449: Install h_db to unbreak some of the lib/libc/db testcases after r305358 r305451: Fix lib/libc/rpc test assumptions added in r305358 - Require root in the tcp/udp subtests (it's needed on FreeBSD when registering services). - Skip the tests if service registration fails. r306367 (by br): Allow up to 6 arguments only on MIPS. r306397 (by br): Use right piece of code for FreeBSD. r309474: Don't build :strvis_locale if VIS_NOLOCALE is undefined The copy of contrib/libc-vis on ^/stable/10 doesn't contain all of the features in the ^/stable/11 // ^/head version, including VIS_NOLOCALE. The risk is lower in conditionally running the test instead of backporting the newer version of libc-vis --- bin/cat/tests/Makefile | 10 +- contrib/netbsd-tests/bin/cat/d_align.in | 2 + contrib/netbsd-tests/bin/cat/d_align.out | 2 + contrib/netbsd-tests/bin/cat/d_se_output.in | 3 + contrib/netbsd-tests/bin/cat/d_se_output.out | 3 + contrib/netbsd-tests/bin/cat/t_cat.sh | 14 +- contrib/netbsd-tests/bin/sh/dotcmd/scoped_command | 25 +- contrib/netbsd-tests/bin/sh/dotcmd/t_dotcmd.sh | 6 +- contrib/netbsd-tests/bin/sh/t_arith.sh | 1035 ++ contrib/netbsd-tests/bin/sh/t_cmdsub.sh | 783 + contrib/netbsd-tests/bin/sh/t_compexit.sh | 63 - contrib/netbsd-tests/bin/sh/t_evaltested.sh | 6 +- contrib/netbsd-tests/bin/sh/t_exit.sh | 120 +- contrib/netbsd-tests/bin/sh/t_expand.sh | 296 +- contrib/netbsd-tests/bin/sh/t_fsplit.sh | 244 +- contrib/netbsd-tests/bin/sh/t_here.sh | 536 +- contrib/netbsd-tests/bin/sh/t_option.sh | 674 + contrib/netbsd-tests/bin/sh/t_redir.sh | 903 ++ contrib/netbsd-tests/bin/sh/t_redircloexec.sh | 178 + contrib/netbsd-tests/bin/sh/t_set_e.sh | 42 +- contrib/netbsd-tests/bin/sh/t_shift.sh | 181 + contrib/netbsd-tests/bin/sh/t_ulimit.sh | 23 +- contrib/netbsd-tests/bin/sh/t_varquote.sh | 95 +- contrib/netbsd-tests/bin/sh/t_varval.sh | 251 + contrib/netbsd-tests/bin/sh/t_wait.sh | 152 +- .../netbsd-tests/crypto/opencrypto/t_opencrypto.sh | 10 +- .../netbsd-tests/dev/audio/t_pad_output.bz2.uue | 2027 +-- contrib/netbsd-tests/dev/dm/h_dm.c | 4 +- contrib/netbsd-tests/dev/fss/t_fss.sh | 84 + contrib/netbsd-tests/dev/sysmon/t_swsensor.sh | 12 +- contrib/netbsd-tests/dev/sysmon/t_swwdog.c | 3 +- contrib/netbsd-tests/dev/usb/t_hid.c | 267 + contrib/netbsd-tests/fs/common/fstest_lfs.c | 4 +- contrib/netbsd-tests/fs/common/h_fsmacros.h | 12 +- contrib/netbsd-tests/fs/nfs/nfsservice/mountd.c | 2575 ---- contrib/netbsd-tests/fs/nfs/nfsservice/nfsd.c | 571 - contrib/netbsd-tests/fs/nfs/nfsservice/rumpnfsd.c | 5 +- contrib/netbsd-tests/fs/nfs/t_rquotad.sh | 4 +- contrib/netbsd-tests/fs/tmpfs/t_vnd.sh | 8 +- contrib/netbsd-tests/fs/vfs/t_io.c | 20 +- contrib/netbsd-tests/fs/vfs/t_renamerace.c | 4 +- contrib/netbsd-tests/fs/vfs/t_unpriv.c | 4 +- contrib/netbsd-tests/fs/vfs/t_vnops.c | 105 +- contrib/netbsd-tests/games/t_factor.sh | 43 +- contrib/netbsd-tests/h_macros.h | 6 +- contrib/netbsd-tests/include/sys/t_bitops.c | 204 +- contrib/netbsd-tests/include/sys/t_cdefs.c | 116 +- contrib/netbsd-tests/include/sys/t_pslist.c | 125 + contrib/netbsd-tests/include/sys/t_socket.c | 4 +- contrib/netbsd-tests/include/t_paths.c | 23 +- contrib/netbsd-tests/ipf/expected/n14 | 6 +- contrib/netbsd-tests/ipf/expected/n14_6 | 6 +- contrib/netbsd-tests/ipf/t_filter_parse.sh | 3 +- contrib/netbsd-tests/ipf/t_nat_exec.sh | 6 +- contrib/netbsd-tests/kernel/kqueue/t_ioctl.c | 7 +- contrib/netbsd-tests/kernel/kqueue/t_proc1.c | 9 +- contrib/netbsd-tests/kernel/kqueue/t_proc2.c | 7 +- contrib/netbsd-tests/kernel/kqueue/t_proc3.c | 6 +- contrib/netbsd-tests/kernel/kqueue/t_vnode.c | 533 + contrib/netbsd-tests/kernel/t_rnd.c | 25 +- contrib/netbsd-tests/lib/libbpfjit/t_bpfjit.c | 966 +- .../netbsd-tests/lib/libc/arch/ia64/return_one.S | 11 +- .../lib/libc/arch/powerpc/return_one.S | 5 +- .../netbsd-tests/lib/libc/arch/riscv/return_one.S | 4 +- contrib/netbsd-tests/lib/libc/db/h_lfsr.c | 179 + contrib/netbsd-tests/lib/libc/db/t_db.sh | 101 +- contrib/netbsd-tests/lib/libc/db/t_db_hash_seq.c | 343 + .../netbsd-tests/lib/libc/gen/execve/t_execve.c | 5 +- contrib/netbsd-tests/lib/libc/gen/isqemu.h | 28 +- .../lib/libc/gen/posix_spawn/t_spawn.c | 4 +- contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c | 29 +- contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c | 25 +- contrib/netbsd-tests/lib/libc/gen/t_nice.c | 2 +- contrib/netbsd-tests/lib/libc/gen/t_randomid.c | 22 +- contrib/netbsd-tests/lib/libc/gen/t_siginfo.c | 25 +- contrib/netbsd-tests/lib/libc/gen/t_sleep.c | 5 +- contrib/netbsd-tests/lib/libc/gen/t_time.c | 13 +- contrib/netbsd-tests/lib/libc/gen/t_vis.c | 45 +- contrib/netbsd-tests/lib/libc/inet/t_inet_addr.c | 109 + .../netbsd-tests/lib/libc/inet/t_inet_network.c | 68 +- contrib/netbsd-tests/lib/libc/net/t_servent.sh | 4 +- contrib/netbsd-tests/lib/libc/rpc/t_rpc.c | 279 +- .../netbsd-tests/lib/libc/stdio/t_open_memstream.c | 96 + contrib/netbsd-tests/lib/libc/stdlib/t_getenv.c | 6 +- .../lib/libc/stdlib/t_posix_memalign.c | 75 +- contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c | 10 +- contrib/netbsd-tests/lib/libc/stdlib/t_strtoi.c | 304 + contrib/netbsd-tests/lib/libc/stdlib/t_strtol.c | 13 +- contrib/netbsd-tests/lib/libc/string/t_memset.c | 52 +- .../lib/libc/sync/cpp_atomic_ops_linkable.cc | 119 + contrib/netbsd-tests/lib/libc/sys/t_bind.c | 78 + contrib/netbsd-tests/lib/libc/sys/t_connect.c | 31 +- contrib/netbsd-tests/lib/libc/sys/t_getcontext.c | 6 + contrib/netbsd-tests/lib/libc/sys/t_getrusage.c | 6 +- contrib/netbsd-tests/lib/libc/sys/t_getsockname.c | 82 + contrib/netbsd-tests/lib/libc/sys/t_kevent.c | 14 +- contrib/netbsd-tests/lib/libc/sys/t_mlock.c | 37 +- contrib/netbsd-tests/lib/libc/sys/t_mmap.c | 71 +- contrib/netbsd-tests/lib/libc/sys/t_mprotect.c | 17 +- .../netbsd-tests/lib/libc/sys/t_posix_fallocate.c | 63 + contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c | 24 +- contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c | 155 +- contrib/netbsd-tests/lib/libc/sys/t_wait.c | 265 + contrib/netbsd-tests/lib/libc/time/t_strptime.c | 257 +- .../lib/libcurses/director/testlang_parse.y | 5 +- contrib/netbsd-tests/lib/libm/t_exp.c | 41 +- contrib/netbsd-tests/lib/libm/t_fenv.c | 220 + contrib/netbsd-tests/lib/libm/t_fmod.c | 9 +- contrib/netbsd-tests/lib/libm/t_hypot.c | 81 + contrib/netbsd-tests/lib/libm/t_log.c | 16 +- contrib/netbsd-tests/lib/libm/t_pow.c | 7 +- contrib/netbsd-tests/lib/libpthread/t_cond.c | 25 +- contrib/netbsd-tests/lib/libpthread/t_mutex.c | 278 +- contrib/netbsd-tests/lib/libpthread/t_rwlock.c | 20 +- contrib/netbsd-tests/lib/librumpclient/t_exec.sh | 4 +- contrib/netbsd-tests/lib/librumpclient/t_fd.c | 4 +- contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh | 16 +- contrib/netbsd-tests/lib/libusbhid/hid_test_data.c | 137 + contrib/netbsd-tests/lib/libusbhid/t_usbhid.c | 449 + .../netbsd-tests/lib/libusbhid/test_usb_hid_usages | 17 + contrib/netbsd-tests/lib/libutil/t_parsedate.c | 473 +- contrib/netbsd-tests/net/arp/t_arp.sh | 653 + contrib/netbsd-tests/net/arp/t_dad.sh | 249 + contrib/netbsd-tests/net/bpfilter/t_bpfilter.c | 86 +- contrib/netbsd-tests/net/bpfjit/t_bpfjit.c | 884 +- contrib/netbsd-tests/net/icmp/t_forward.c | 6 +- contrib/netbsd-tests/net/icmp/t_icmp6_redirect.sh | 171 + contrib/netbsd-tests/net/icmp/t_icmp_redirect.sh | 339 + contrib/netbsd-tests/net/icmp/t_ping.c | 8 +- contrib/netbsd-tests/net/icmp/t_ping2.sh | 4 +- contrib/netbsd-tests/net/if/ifconf.c | 134 + contrib/netbsd-tests/net/if/t_ifconf.sh | 100 + contrib/netbsd-tests/net/if/t_ifconfig.sh | 329 + contrib/netbsd-tests/net/if_bridge/t_bridge.sh | 352 +- contrib/netbsd-tests/net/if_gif/t_gif.sh | 778 + contrib/netbsd-tests/net/if_pppoe/t_pppoe.sh | 193 + contrib/netbsd-tests/net/if_tap/t_tap.sh | 198 + contrib/netbsd-tests/net/in_cksum/assym.h | 10 + contrib/netbsd-tests/net/in_cksum/in_cksum.c | 270 + contrib/netbsd-tests/net/in_cksum/t_in_cksum.sh | 78 + contrib/netbsd-tests/net/mcast/mcast.c | 559 + contrib/netbsd-tests/net/mcast/t_mcast.sh | 110 + contrib/netbsd-tests/net/mpls/t_ldp_regen.sh | 11 +- contrib/netbsd-tests/net/mpls/t_mpls_fw.sh | 6 +- contrib/netbsd-tests/net/mpls/t_mpls_fw6.sh | 220 + contrib/netbsd-tests/net/mpls/t_mpls_fw64.sh | 226 + contrib/netbsd-tests/net/mpls/t_rfc4182.sh | 6 +- contrib/netbsd-tests/net/ndp/t_dad.sh | 250 + contrib/netbsd-tests/net/ndp/t_ndp.sh | 454 + contrib/netbsd-tests/net/ndp/t_ra.sh | 166 + contrib/netbsd-tests/net/net/t_forwarding.sh | 563 + contrib/netbsd-tests/net/net/t_ipaddress.sh | 190 + contrib/netbsd-tests/net/net/t_ipv6_lifetime.sh | 133 + contrib/netbsd-tests/net/net/t_ipv6address.sh | 394 + contrib/netbsd-tests/net/net/t_tcp.c | 15 +- contrib/netbsd-tests/net/route/t_change.sh | 255 +- contrib/netbsd-tests/net/route/t_flags.sh | 380 + contrib/netbsd-tests/net/route/t_flags6.sh | 304 + contrib/netbsd-tests/net/route/t_route.sh | 430 + .../netbsd-tests/rump/modautoload/t_modautoload.c | 14 +- .../rump/rumpkern/h_server/h_simpleserver.c | 3 +- contrib/netbsd-tests/rump/rumpkern/t_lwproc.c | 3 +- contrib/netbsd-tests/rump/rumpkern/t_sp.sh | 7 +- contrib/netbsd-tests/rump/rumpnet/t_shmif.sh | 4 +- contrib/netbsd-tests/rump/rumpvfs/t_p2kifs.c | 3 +- contrib/netbsd-tests/sbin/gpt/gpt.2part.show.label | 8 + .../netbsd-tests/sbin/gpt/gpt.2part.show.normal | 8 + contrib/netbsd-tests/sbin/gpt/gpt.2part.show.uuid | 8 + contrib/netbsd-tests/sbin/gpt/gpt.backup | 1851 +++ contrib/netbsd-tests/sbin/gpt/gpt.disklabel | 27 + .../sbin/gpt/gpt.disklabel.show.normal | 12 + .../netbsd-tests/sbin/gpt/gpt.empty.show.normal | 7 + .../sbin/gpt/gpt.removepart.show.normal | 8 + .../sbin/gpt/gpt.resizedisk.show.normal | 9 + .../sbin/gpt/gpt.resizepart.show.normal | 8 + contrib/netbsd-tests/sbin/gpt/t_gpt.sh | 318 + contrib/netbsd-tests/sbin/resize_ffs/common.sh | 4 + contrib/netbsd-tests/sbin/resize_ffs/t_check.sh | 56 + contrib/netbsd-tests/sbin/resize_ffs/t_grow.sh | 4 +- .../netbsd-tests/sbin/resize_ffs/t_grow_swapped.sh | 4 +- contrib/netbsd-tests/sbin/resize_ffs/t_shrink.sh | 4 +- .../sbin/resize_ffs/t_shrink_swapped.sh | 4 +- contrib/netbsd-tests/sbin/sysctl/t_perm.sh | 5 +- contrib/netbsd-tests/share/mk/t_lib.sh | 8 +- contrib/netbsd-tests/share/mk/t_prog.sh | 8 + contrib/netbsd-tests/share/mk/t_test.sh | 4 + contrib/netbsd-tests/sys/net/t_print.c | 172 + contrib/netbsd-tests/sys/netatalk/t_print.c | 135 + contrib/netbsd-tests/sys/netinet/t_print.c | 144 + contrib/netbsd-tests/sys/netinet6/t_print.c | 154 + contrib/netbsd-tests/usr.bin/cc/t_hello.sh | 4 +- contrib/netbsd-tests/usr.bin/config/d_min | 6 + .../netbsd-tests/usr.bin/config/support/conf/files | 15 + contrib/netbsd-tests/usr.bin/config/t_config.sh | 183 +- contrib/netbsd-tests/usr.bin/gdb/t_regress.sh | 77 + contrib/netbsd-tests/usr.bin/ld/t_script.sh | 230 + contrib/netbsd-tests/usr.bin/ld/t_section.sh | 100 + contrib/netbsd-tests/usr.bin/make/t_make.sh | 13 +- contrib/netbsd-tests/usr.bin/netpgpverify/Testspec | 114 + .../usr.bin/netpgpverify/t_netpgpverify.sh | 15190 +++++++++---------- contrib/netbsd-tests/usr.bin/sed/t_sed.sh | 17 +- .../usr.bin/sort/d_any_char_dflag_out.txt | Bin 4 -> 1530 bytes .../usr.bin/sort/d_any_char_fflag_out.txt | Bin 4 -> 1530 bytes .../usr.bin/sort/d_any_char_iflag_out.txt | Bin 4 -> 1530 bytes .../usr.bin/xlint/lint1/d_c99_anon_struct.c | 26 + .../xlint/lint1/d_c99_compound_literal_comma.c | 14 + .../usr.bin/xlint/lint1/d_c99_flex_array_packed.c | 6 + .../usr.bin/xlint/lint1/d_c99_nested_struct.c | 25 + .../usr.bin/xlint/lint1/d_c99_union_init4.c | 15 + .../usr.bin/xlint/lint1/d_cast_fun_array_param.c | 9 + .../usr.bin/xlint/lint1/d_type_question_colon.c | 14 + .../netbsd-tests/usr.bin/xlint/lint1/d_typefun.c | 22 + .../usr.sbin/traceroute/t_traceroute.sh | 4 +- lib/libc/tests/db/Makefile | 2 + lib/libc/tests/hash/Makefile | 2 + lib/libc/tests/inet/Makefile | 3 +- lib/libc/tests/stdio/Makefile | 3 +- lib/libc/tests/stdio/open_memstream2_test.c | 201 + lib/libc/tests/stdio/open_memstream_test.c | 201 - lib/libc/tests/stdlib/Makefile | 2 +- lib/libc/tests/sys/Makefile | 4 + lib/msun/tests/Makefile | 2 + 222 files changed, 33671 insertions(+), 13701 deletions(-) create mode 100644 contrib/netbsd-tests/bin/cat/d_se_output.in create mode 100644 contrib/netbsd-tests/bin/cat/d_se_output.out create mode 100755 contrib/netbsd-tests/bin/sh/t_arith.sh create mode 100755 contrib/netbsd-tests/bin/sh/t_cmdsub.sh delete mode 100755 contrib/netbsd-tests/bin/sh/t_compexit.sh create mode 100755 contrib/netbsd-tests/bin/sh/t_option.sh create mode 100755 contrib/netbsd-tests/bin/sh/t_redir.sh create mode 100755 contrib/netbsd-tests/bin/sh/t_redircloexec.sh create mode 100755 contrib/netbsd-tests/bin/sh/t_shift.sh create mode 100755 contrib/netbsd-tests/bin/sh/t_varval.sh create mode 100755 contrib/netbsd-tests/dev/fss/t_fss.sh create mode 100644 contrib/netbsd-tests/dev/usb/t_hid.c delete mode 100644 contrib/netbsd-tests/fs/nfs/nfsservice/mountd.c delete mode 100644 contrib/netbsd-tests/fs/nfs/nfsservice/nfsd.c create mode 100644 contrib/netbsd-tests/include/sys/t_pslist.c create mode 100644 contrib/netbsd-tests/kernel/kqueue/t_vnode.c create mode 100644 contrib/netbsd-tests/lib/libc/db/h_lfsr.c create mode 100644 contrib/netbsd-tests/lib/libc/db/t_db_hash_seq.c create mode 100644 contrib/netbsd-tests/lib/libc/inet/t_inet_addr.c create mode 100644 contrib/netbsd-tests/lib/libc/stdio/t_open_memstream.c create mode 100644 contrib/netbsd-tests/lib/libc/stdlib/t_strtoi.c create mode 100644 contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc create mode 100644 contrib/netbsd-tests/lib/libc/sys/t_bind.c create mode 100644 contrib/netbsd-tests/lib/libc/sys/t_getsockname.c create mode 100644 contrib/netbsd-tests/lib/libc/sys/t_posix_fallocate.c create mode 100644 contrib/netbsd-tests/lib/libc/sys/t_wait.c create mode 100644 contrib/netbsd-tests/lib/libm/t_fenv.c create mode 100644 contrib/netbsd-tests/lib/libm/t_hypot.c create mode 100644 contrib/netbsd-tests/lib/libusbhid/hid_test_data.c create mode 100644 contrib/netbsd-tests/lib/libusbhid/t_usbhid.c create mode 100644 contrib/netbsd-tests/lib/libusbhid/test_usb_hid_usages create mode 100755 contrib/netbsd-tests/net/arp/t_arp.sh create mode 100755 contrib/netbsd-tests/net/arp/t_dad.sh create mode 100755 contrib/netbsd-tests/net/icmp/t_icmp6_redirect.sh create mode 100755 contrib/netbsd-tests/net/icmp/t_icmp_redirect.sh create mode 100644 contrib/netbsd-tests/net/if/ifconf.c create mode 100755 contrib/netbsd-tests/net/if/t_ifconf.sh create mode 100755 contrib/netbsd-tests/net/if/t_ifconfig.sh create mode 100755 contrib/netbsd-tests/net/if_gif/t_gif.sh create mode 100755 contrib/netbsd-tests/net/if_pppoe/t_pppoe.sh create mode 100755 contrib/netbsd-tests/net/if_tap/t_tap.sh create mode 100644 contrib/netbsd-tests/net/in_cksum/assym.h create mode 100644 contrib/netbsd-tests/net/in_cksum/in_cksum.c create mode 100755 contrib/netbsd-tests/net/in_cksum/t_in_cksum.sh create mode 100644 contrib/netbsd-tests/net/mcast/mcast.c create mode 100755 contrib/netbsd-tests/net/mcast/t_mcast.sh create mode 100755 contrib/netbsd-tests/net/mpls/t_mpls_fw6.sh create mode 100755 contrib/netbsd-tests/net/mpls/t_mpls_fw64.sh create mode 100755 contrib/netbsd-tests/net/ndp/t_dad.sh create mode 100755 contrib/netbsd-tests/net/ndp/t_ndp.sh create mode 100755 contrib/netbsd-tests/net/ndp/t_ra.sh create mode 100755 contrib/netbsd-tests/net/net/t_forwarding.sh create mode 100755 contrib/netbsd-tests/net/net/t_ipaddress.sh create mode 100755 contrib/netbsd-tests/net/net/t_ipv6_lifetime.sh create mode 100755 contrib/netbsd-tests/net/net/t_ipv6address.sh create mode 100755 contrib/netbsd-tests/net/route/t_flags.sh create mode 100755 contrib/netbsd-tests/net/route/t_flags6.sh create mode 100755 contrib/netbsd-tests/net/route/t_route.sh create mode 100644 contrib/netbsd-tests/sbin/gpt/gpt.2part.show.label create mode 100644 contrib/netbsd-tests/sbin/gpt/gpt.2part.show.normal create mode 100644 contrib/netbsd-tests/sbin/gpt/gpt.2part.show.uuid create mode 100644 contrib/netbsd-tests/sbin/gpt/gpt.backup create mode 100644 contrib/netbsd-tests/sbin/gpt/gpt.disklabel create mode 100644 contrib/netbsd-tests/sbin/gpt/gpt.disklabel.show.normal create mode 100644 contrib/netbsd-tests/sbin/gpt/gpt.empty.show.normal create mode 100644 contrib/netbsd-tests/sbin/gpt/gpt.removepart.show.normal create mode 100644 contrib/netbsd-tests/sbin/gpt/gpt.resizedisk.show.normal create mode 100644 contrib/netbsd-tests/sbin/gpt/gpt.resizepart.show.normal create mode 100755 contrib/netbsd-tests/sbin/gpt/t_gpt.sh create mode 100755 contrib/netbsd-tests/sbin/resize_ffs/t_check.sh create mode 100644 contrib/netbsd-tests/sys/net/t_print.c create mode 100644 contrib/netbsd-tests/sys/netatalk/t_print.c create mode 100644 contrib/netbsd-tests/sys/netinet/t_print.c create mode 100644 contrib/netbsd-tests/sys/netinet6/t_print.c create mode 100644 contrib/netbsd-tests/usr.bin/config/d_min create mode 100755 contrib/netbsd-tests/usr.bin/gdb/t_regress.sh create mode 100755 contrib/netbsd-tests/usr.bin/ld/t_script.sh create mode 100755 contrib/netbsd-tests/usr.bin/ld/t_section.sh create mode 100644 contrib/netbsd-tests/usr.bin/netpgpverify/Testspec create mode 100644 contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_struct.c create mode 100644 contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_compound_literal_comma.c create mode 100644 contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_flex_array_packed.c create mode 100644 contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_nested_struct.c create mode 100644 contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init4.c create mode 100644 contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_fun_array_param.c create mode 100644 contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_question_colon.c create mode 100644 contrib/netbsd-tests/usr.bin/xlint/lint1/d_typefun.c create mode 100644 lib/libc/tests/stdio/open_memstream2_test.c delete mode 100644 lib/libc/tests/stdio/open_memstream_test.c diff --git a/bin/cat/tests/Makefile b/bin/cat/tests/Makefile index f68513c..8ac1ffb 100644 --- a/bin/cat/tests/Makefile +++ b/bin/cat/tests/Makefile @@ -4,9 +4,17 @@ NETBSD_ATF_TESTS_SH= cat_test FILESDIR= ${TESTSDIR} -FILES= d_align.in +FILES+= d_align.in FILES+= d_align.out +FILES+= d_se_output.in +FILES+= d_se_output.out .include +d_align.out: ${TESTSRC}/d_align.out + sed -E -e 's,^[[:space:]]{7}\$$$$,\$$,' < ${.ALLSRC} > ${.TARGET}.tmp + mv ${.TARGET}.tmp ${.TARGET} + +CLEANFILES+= d_align.out d_align.out.tmp + .include diff --git a/contrib/netbsd-tests/bin/cat/d_align.in b/contrib/netbsd-tests/bin/cat/d_align.in index 31bf4a7..37d30c7 100644 --- a/contrib/netbsd-tests/bin/cat/d_align.in +++ b/contrib/netbsd-tests/bin/cat/d_align.in @@ -1,3 +1,5 @@ a b c + 1 2 3 + x y z diff --git a/contrib/netbsd-tests/bin/cat/d_align.out b/contrib/netbsd-tests/bin/cat/d_align.out index fd32469..4f44c00 100644 --- a/contrib/netbsd-tests/bin/cat/d_align.out +++ b/contrib/netbsd-tests/bin/cat/d_align.out @@ -1,3 +1,5 @@ 1 a b c$ + $ 2 1 2 3$ + $ 3 x y z$ diff --git a/contrib/netbsd-tests/bin/cat/d_se_output.in b/contrib/netbsd-tests/bin/cat/d_se_output.in new file mode 100644 index 0000000..0d3c8c1 --- /dev/null +++ b/contrib/netbsd-tests/bin/cat/d_se_output.in @@ -0,0 +1,3 @@ + +Of course it runs NetBSD + diff --git a/contrib/netbsd-tests/bin/cat/d_se_output.out b/contrib/netbsd-tests/bin/cat/d_se_output.out new file mode 100644 index 0000000..c4767c3 --- /dev/null +++ b/contrib/netbsd-tests/bin/cat/d_se_output.out @@ -0,0 +1,3 @@ +$ +Of course it runs NetBSD$ +$ diff --git a/contrib/netbsd-tests/bin/cat/t_cat.sh b/contrib/netbsd-tests/bin/cat/t_cat.sh index 1b7a930..799a748 100755 --- a/contrib/netbsd-tests/bin/cat/t_cat.sh +++ b/contrib/netbsd-tests/bin/cat/t_cat.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_cat.sh,v 1.2 2012/03/27 17:57:02 jruoho Exp $ +# $NetBSD: t_cat.sh,v 1.3 2016/06/16 01:04:58 sevan Exp $ # # Copyright (c) 2012 The NetBSD Foundation, Inc. # All rights reserved. @@ -52,8 +52,20 @@ nonexistent_body() { -x "cat /some/name/that/does/not/exist" } +atf_test_case se_output +se_output_head() { + atf_set "descr" "Test that cat(1) prints a $ sign " \ + "on blank lines with options '-se' (PR bin/51250)" +} + +se_output_body() { + atf_check -s ignore -o file:$(atf_get_srcdir)/d_se_output.out \ + -x "cat -se $(atf_get_srcdir)/d_se_output.in" +} + atf_init_test_cases() { atf_add_test_case align atf_add_test_case nonexistent + atf_add_test_case se_output } diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/scoped_command b/contrib/netbsd-tests/bin/sh/dotcmd/scoped_command index fda4e53..36e712b 100755 --- a/contrib/netbsd-tests/bin/sh/dotcmd/scoped_command +++ b/contrib/netbsd-tests/bin/sh/dotcmd/scoped_command @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: scoped_command,v 1.1 2014/05/31 14:29:06 christos Exp $ +# $NetBSD: scoped_command,v 1.2 2016/03/27 14:57:50 christos Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -30,6 +30,27 @@ # POSSIBILITY OF SUCH DAMAGE. # +: ${TEST_SH:=/bin/sh} + +sane_sh() +{ + set -- ${TEST_SH} + case "$#" in + (0) set /bin/sh;; + (1|2) ;; + (*) set "$1";; # Just ignore options if we cannot make them work + esac + + case "$1" in + /*) TEST_SH="$1${2+ }$2";; + ./*) TEST_SH="${PWD}${1#.}${2+ }$2";; + */*) TEST_SH="${PWD}/$1${2+ }$2";; + *) TEST_SH="$( command -v "$1" )${2+ }$2";; + esac +} + +sane_sh + set -e # USAGE: @@ -52,7 +73,7 @@ cmd="echo 'before ${3}' ${2} echo 'after ${3}, return value:' ${?}" -echo "#!/bin/sh" +echo "#!${TEST_SH}" [ 'func' = "${1}" ] && cat </dev/null + then + # 16 bits or less, or hex unsupported, just give up... + return + fi + test $( ${TEST_SH} -c 'echo $(( 0x1FFFF ))' ) = 131071 || return + + # when attempting to exceed the number of available bits + # the shell may react in any of 3 (rational) ways + # 1. syntax error (maybe even core dump...) and fail + # 2. represent a positive number input as negative value + # 3. keep the number positive, but not the value expected + # (perhaps pegged at the max possible value) + # any of those may be accompanied by a message to stderr + + # Must check all 3 possibilities for each plausible size + # Tests do not use 0x8000... because that value can have weird + # other side effects that are not relevant to discover here. + # But we do want to try and force the sign bit set. + + if ! ${TEST_SH} -c ': $(( 0xC0000000 ))' 2>/dev/null + then + # proobably shell detected overflow and complained + ARITH_BITS=32 + return + fi + if ${TEST_SH} 2>/dev/null \ + -c 'case $(( 0xC0000000 )); in (-*) exit 0;; esac; exit 1' + then + ARITH_BITS=32 + return + fi + if ${TEST_SH} -c '[ $(( 0xC0000000 )) != 3221225472 ]' 2>/dev/null + then + ARITH_BITS=32 + return + fi + + if ! ${TEST_SH} -c ': $(( 0xC000000000000000 ))' 2>/dev/null + then + ARITH_BITS=64 + return + fi + if ${TEST_SH} 2>/dev/null \ + -c 'case $(( 0xC000000000000000 )); in (-*) exit 0;; esac; exit 1' + then + ARITH_BITS=64 + return + fi + if ${TEST_SH} 2>/dev/null \ + -c '[ $((0xC000000000000000)) != 13835058055282163712 ]' + then + ARITH_BITS=64 + return + fi + + if ${TEST_SH} 2>/dev/null -c \ + '[ $((0x123456781234567812345678)) = 5634002657842756053938493048 ]' + then + # just assume... (for now anyway, revisit when it happens...) + ARITH_BITS=96 + return + fi +} + +atf_test_case constants +constants_head() +{ + atf_set "descr" "Tests that arithmetic expansion can handle constants" +} +constants_body() +{ + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $((0x0))' + + # atf_expect_fail "PR bin/50959" + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $((0X0))' + # atf_expect_pass + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $((000))' + + atf_check -s exit:0 -o inline:'1\n' -e empty \ + ${TEST_SH} -c 'echo $(( 000000001 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty \ + ${TEST_SH} -c 'echo $(( 0x000000 ))' + + atf_check -s exit:0 -o inline:'99999\n' -e empty \ + ${TEST_SH} -c 'echo $((99999))' + + [ ${ARITH_BITS} -gt 44 ] && + atf_check -s exit:0 -o inline:'9191919191919\n' -e empty \ + ${TEST_SH} -c 'echo $((9191919191919))' + + atf_check -s exit:0 -o inline:'13\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0xD ))' + atf_check -s exit:0 -o inline:'11\n' -e empty ${TEST_SH} -c \ + 'echo $(( 013 ))' + atf_check -s exit:0 -o inline:'7\n' -e empty ${TEST_SH} -c \ + 'x=7;echo $(($x))' + atf_check -s exit:0 -o inline:'9\n' -e empty ${TEST_SH} -c \ + 'x=9;echo $((x))' + + atf_check -s exit:0 -o inline:'11\n' -e empty \ + ${TEST_SH} -c 'x=0xB; echo $(( $x ))' + atf_check -s exit:0 -o inline:'27\n' -e empty \ + ${TEST_SH} -c 'x=0X1B; echo $(( x ))' + atf_check -s exit:0 -o inline:'27\n' -e empty \ + ${TEST_SH} -c 'X=033; echo $(( $X ))' + atf_check -s exit:0 -o inline:'219\n' -e empty \ + ${TEST_SH} -c 'X=0333; echo $(( X ))' + atf_check -s exit:0 -o inline:'0\n' -e empty \ + ${TEST_SH} -c 'NULL=; echo $(( NULL ))' + + # Not clear if this is 0, nothing, or an error, so omit for now + # atf_check -s exit:0 -o inline:'0\n' -e empty \ + # ${TEST_SH} -c 'echo $(( ))' + + # not clear whether this should return 0 or an error, so omit for now + # atf_check -s exit:0 -o inline:'0\n' -e empty \ + # ${TEST_SH} -c 'echo $(( UNDEFINED_VAR ))' +} + + +atf_test_case do_unary_plus +do_unary_plus_head() +{ + atf_set "descr" "Tests that unary plus works as expected" +} +do_unary_plus_body() +{ + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( +0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( +1 ))' + atf_check -s exit:0 -o inline:'6\n' -e empty ${TEST_SH} -c \ + 'echo $(( + 6 ))' + atf_check -s exit:0 -o inline:'4321\n' -e empty ${TEST_SH} -c \ + 'echo $(( + 4321 ))' + atf_check -s exit:0 -o inline:'17185\n' -e empty ${TEST_SH} -c \ + 'echo $(( + 0x4321 ))' +} + +atf_test_case do_unary_minus +do_unary_minus_head() +{ + atf_set "descr" "Tests that unary minus works as expected" +} +do_unary_minus_body() +{ + atf_check -s exit:0 -o inline:'-1\n' -e empty ${TEST_SH} -c \ + 'echo $(( -1 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( - 0 ))' + atf_check -s exit:0 -o inline:'-1\n' -e empty ${TEST_SH} -c \ + 'echo $(( - 1 ))' + atf_check -s exit:0 -o inline:'-6\n' -e empty ${TEST_SH} -c \ + 'echo $(( - 6 ))' + atf_check -s exit:0 -o inline:'-4321\n' -e empty ${TEST_SH} -c \ + 'echo $(( - 4321 ))' + atf_check -s exit:0 -o inline:'-2257\n' -e empty ${TEST_SH} -c \ + 'echo $(( - 04321 ))' + atf_check -s exit:0 -o inline:'-7\n' -e empty ${TEST_SH} -c \ + 'echo $((-7))' +} + +atf_test_case do_unary_not +do_unary_not_head() +{ + atf_set "descr" "Tests that unary not (boolean) works as expected" +} +do_unary_not_body() +{ + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( ! 1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( ! 0 ))' + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( !1234 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( !0xFFFF ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( ! 000000 ))' +} + +atf_test_case do_unary_tilde +do_unary_tilde_head() +{ + atf_set "descr" "Tests that unary not (bitwise) works as expected" +} +do_unary_tilde_body() +{ + # definitely 2's complement arithmetic here... + + atf_check -s exit:0 -o inline:'-1\n' -e empty ${TEST_SH} -c \ + 'echo $(( ~ 0 ))' + atf_check -s exit:0 -o inline:'-2\n' -e empty ${TEST_SH} -c \ + 'echo $(( ~ 1 ))' + + atf_check -s exit:0 -o inline:'-1235\n' -e empty ${TEST_SH} -c \ + 'echo $(( ~1234 ))' + atf_check -s exit:0 -o inline:'-256\n' -e empty ${TEST_SH} -c \ + 'echo $(( ~0xFF ))' +} + +atf_test_case elementary_add +elementary_add_head() +{ + atf_set "descr" "Tests that simple addition works as expected" +} +elementary_add_body() +{ + # some of these tests actually test unary ops & op precedence... + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 + 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 + 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 + 1 ))' + atf_check -s exit:0 -o inline:'2\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 + 1 ))' + atf_check -s exit:0 -o inline:'10\n' -e empty ${TEST_SH} -c \ + 'echo $(( 4 + 6 ))' + atf_check -s exit:0 -o inline:'10\n' -e empty ${TEST_SH} -c \ + 'echo $(( 6 + 4 ))' + atf_check -s exit:0 -o inline:'5555\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1234 + 4321 ))' + atf_check -s exit:0 -o inline:'3333\n' -e empty ${TEST_SH} -c \ + 'echo $((1111+2222))' + atf_check -s exit:0 -o inline:'5555\n' -e empty ${TEST_SH} -c \ + 'echo $((+3333+2222))' + atf_check -s exit:0 -o inline:'7777\n' -e empty ${TEST_SH} -c \ + 'echo $((+3333 + +4444))' + atf_check -s exit:0 -o inline:'-7777\n' -e empty ${TEST_SH} -c \ + 'echo -$((+4125+ +3652))' +} + +atf_test_case elementary_sub +elementary_sub_head() +{ + atf_set "descr" "Tests that simple subtraction works as expected" +} +elementary_sub_body() +{ + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 - 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 - 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 - 1 ))' + atf_check -s exit:0 -o inline:'-1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 - 1 ))' + atf_check -s exit:0 -o inline:'488\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1066 - 578 ))' + atf_check -s exit:0 -o inline:'-3662\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2016-5678 ))' + atf_check -s exit:0 -o inline:'-3662\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2016+-5678 ))' + atf_check -s exit:0 -o inline:'-3662\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2016-+5678 ))' + atf_check -s exit:0 -o inline:'-7694\n' -e empty ${TEST_SH} -c \ + 'echo $(( -2016-5678 ))' + atf_check -s exit:0 -o inline:'--1\n' -e empty ${TEST_SH} -c \ + 'echo -$(( -1018 - -1017 ))' +} + +atf_test_case elementary_mul +elementary_mul_head() +{ + atf_set "descr" "Tests that simple multiplication works as expected" +} +elementary_mul_body() +{ + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 * 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 * 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 * 1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 * 1 ))' + atf_check -s exit:0 -o inline:'-1\n' -e empty ${TEST_SH} -c \ + 'echo $(( -1 * 1 ))' + atf_check -s exit:0 -o inline:'-1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 * -1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( -1 * -1 ))' + atf_check -s exit:0 -o inline:'391\n' -e empty ${TEST_SH} -c \ + 'echo $(( 17 * 23 ))' + atf_check -s exit:0 -o inline:'169\n' -e empty ${TEST_SH} -c \ + 'echo $(( 13*13 ))' + atf_check -s exit:0 -o inline:'-11264\n' -e empty ${TEST_SH} -c \ + 'echo $(( -11 *1024 ))' + atf_check -s exit:0 -o inline:'-16983\n' -e empty ${TEST_SH} -c \ + 'echo $(( 17* -999 ))' + atf_check -s exit:0 -o inline:'9309\n' -e empty ${TEST_SH} -c \ + 'echo $(( -29*-321 ))' +} + +atf_test_case elementary_div +elementary_div_head() +{ + atf_set "descr" "Tests that simple division works as expected" +} +elementary_div_body() +{ + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 / 1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 / 1 ))' + test ${ARITH_BITS} -ge 38 && + atf_check -s exit:0 -o inline:'99999999999\n' -e empty \ + ${TEST_SH} -c 'echo $(( 99999999999 / 1 ))' + atf_check -s exit:0 -o inline:'2\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2 / 1 ))' + + atf_check -s exit:0 -o inline:'3\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 / 1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 / 2 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 / 3 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 / 4 ))' + + atf_check -s exit:0 -o inline:'173\n' -e empty ${TEST_SH} -c \ + 'echo $(( 123456 / 713 ))' + atf_check -s exit:0 -o inline:'13\n' -e empty ${TEST_SH} -c \ + 'echo $(( 169 / 13 ))' +} + +atf_test_case elementary_rem +elementary_rem_head() +{ + atf_set "descr" "Tests that simple modulus works as expected" +} +elementary_rem_body() +{ + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 % 1 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 % 1 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2 % 1 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 9999 % 1 ))' + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 % 2 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 % 2 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2 % 2 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0xFFFF % 2 ))' + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 % 3 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 % 3 ))' + atf_check -s exit:0 -o inline:'2\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2 % 3 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 % 3 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3123 % 3 ))' + + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 9999 % 2 ))' + + atf_check -s exit:0 -o inline:'107\n' -e empty ${TEST_SH} -c \ + 'echo $(( 123456%173 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $((169%13))' +} + +atf_test_case elementary_shl +elementary_shl_head() +{ + atf_set "descr" "Tests that simple shift left works as expected" +} +elementary_shl_body() +{ + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 << 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 << 1 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 << 17 ))' + + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 << 0 ))' + atf_check -s exit:0 -o inline:'2\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 << 1 ))' + atf_check -s exit:0 -o inline:'131072\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 << 17 ))' + + atf_check -s exit:0 -o inline:'2021161080\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x3C3C3C3C << 1 ))' + + test "${ARITH_BITS}" -ge 40 && + atf_check -s exit:0 -o inline:'129354309120\n' -e empty \ + ${TEST_SH} -c 'echo $(( 0x3C3C3C3C << 7 ))' + test "${ARITH_BITS}" -ge 72 && + atf_check -s exit:0 -o inline:'1111145054534149079040\n' \ + -e empty ${TEST_SH} -c 'echo $(( 0x3C3C3C3C << 40 ))' + + return 0 +} + +atf_test_case elementary_shr +elementary_shr_head() +{ + atf_set "descr" "Tests that simple shift right works as expected" +} +elementary_shr_body() +{ + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 >> 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 >> 1 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 >> 17 ))' + + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 >> 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 >> 1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2 >> 1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 >> 1 ))' + + atf_check -s exit:0 -o inline:'4\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x10 >> 2 ))' + atf_check -s exit:0 -o inline:'4\n' -e empty ${TEST_SH} -c \ + 'echo $(( 022 >> 2 ))' + + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 131072 >> 17 ))' + + test ${ARITH_BITS} -ge 40 && + atf_check -s exit:0 -o inline:'8\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x4000000000 >> 35 ))' + test ${ARITH_BITS} -ge 80 && + atf_check -s exit:0 -o inline:'4464\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x93400FACE005C871000 >> 64 ))' + + return 0 +} + +atf_test_case elementary_eq +elementary_eq_head() +{ + atf_set "descr" "Tests that simple equality test works as expected" +} +elementary_eq_body() +{ + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 == 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 == 0000 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 == 0x00 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 == 1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'X=30; Y=0x1E; echo $(( X == Y ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x1234 == 4660 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x1234 == 011064 ))' + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 == 1 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 == 0000000000000001 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 == 0x10000000000000 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 == 2 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'X=3; Y=7; echo $(( X == Y ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1234 == 0x4660 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 01234 == 0x11064 ))' +} +atf_test_case elementary_ne +elementary_ne_head() +{ + atf_set "descr" "Tests that simple inequality test works as expected" +} +elementary_ne_body() +{ + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 != 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x71 != 17 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1234 != 01234 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x1234 != 01234 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'X=3; echo $(( X != 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'X=3; Y=0x11; echo $(( X != Y ))' + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 != 3 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 != 0x0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0xA != 012 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'X=1; echo $(( X != 1 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'X=0xC; Y=014; echo $(( X != Y ))' +} +atf_test_case elementary_lt +elementary_lt_head() +{ + atf_set "descr" "Tests that simple less than test works as expected" +} +elementary_lt_body() +{ + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 < 1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( -1 < 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 < 10 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 100 < 101 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0xA1 < 200 ))' + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 < 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 < 0 ))' + + test ${ARITH_BITS} -ge 40 && + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x1BEEFF00D < 0x1FACECAFE ))' + + return 0 +} +atf_test_case elementary_le +elementary_le_head() +{ + atf_set "descr" "Tests that simple less or equal test works as expected" +} +elementary_le_body() +{ + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 <= 1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( -1 <= 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 <= 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 <= 10 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 100 <= 101 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0xA1 <= 161 ))' + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 <= 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( -100 <= -200 ))' + + test ${ARITH_BITS} -ge 40 && + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'cost=; AUD=; echo $(( $cost 0x2FEEDBABE <= $AUD 12866927294 ))' + + return 0 +} +atf_test_case elementary_gt +elementary_gt_head() +{ + atf_set "descr" "Tests that simple greater than works as expected" +} +elementary_gt_body() +{ + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 > 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 > -1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 11 > 012 ))' + + # atf_expect_fail "PR bin/50959" + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2147483647 > 0X7FFFFF0 ))' + # atf_expect_pass + + test ${ARITH_BITS} -gt 32 && + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x80000000 > 0x7FFFFFFF ))' + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 > 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 > 1 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( -1 > 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 > 10 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2015 > 2016 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0xA1 > 200 ))' + + test ${ARITH_BITS} -ge 44 && + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x7F07F07F0 > 34099628014 ))' + + return 0 +} +atf_test_case elementary_ge +elementary_ge_head() +{ + atf_set "descr" "Tests that simple greater or equal works as expected" +} +elementary_ge_body() +{ + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 >= 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 >= 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( -100 >= -101 ))' + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( -1 >= 0 ))' +} + +atf_test_case fiddle_bits_and +fiddle_bits_and_head() +{ + atf_set "descr" "Test bitwise and operations in arithmetic expressions" +} +fiddle_bits_and_body() +{ + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 & 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 & 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 & 1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 & 1 ))' + + atf_check -s exit:0 -o inline:'255\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0xFF & 0xFF ))' + atf_check -s exit:0 -o inline:'255\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0xFFFF & 0377 ))' + + test "${ARITH_BITS}" -ge 48 && + atf_check -s exit:0 -o inline:'70377641607203\n' -e empty \ + ${TEST_SH} -c 'echo $(( 0x5432FEDC0123 & 0x42871357BAB3 ))' + + return 0 +} +atf_test_case fiddle_bits_or +fiddle_bits_or_head() +{ + atf_set "descr" "Test bitwise or operations in arithmetic expressions" +} +fiddle_bits_or_body() +{ + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 | 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 | 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 | 1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 | 1 ))' + + atf_check -s exit:0 -o inline:'4369\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x1111 | 0x1111 ))' + atf_check -s exit:0 -o inline:'255\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0xAA | 0125 ))' + + test "${ARITH_BITS}" -ge 48 && + atf_check -s exit:0 -o inline:'95348271856563\n' -e empty \ + ${TEST_SH} -c 'echo $(( 0x5432FEDC0123 | 0x42871357BAB3 ))' + + return 0 +} +atf_test_case fiddle_bits_xor +fiddle_bits_xor_head() +{ + atf_set "descr" "Test bitwise xor operations in arithmetic expressions" +} +fiddle_bits_xor_body() +{ + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 ^ 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 ^ 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 ^ 1 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 ^ 1 ))' + + atf_check -s exit:0 -o inline:'255\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0xF0 ^ 0x0F ))' + atf_check -s exit:0 -o inline:'15\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0xF0 ^ 0xFF ))' + + test "${ARITH_BITS}" -ge 48 && + atf_check -s exit:0 -o inline:'24970630249360\n' -e empty \ + ${TEST_SH} -c 'echo $(( 0x5432FEDC0123 ^ 0x42871357BAB3 ))' + + return 0 +} + +atf_test_case logical_and +logical_and_head() +{ + atf_set "descr" "Test logical and operations in arithmetic expressions" +} +logical_and_body() +{ + # cannot test short-circuit eval until sh implements side effects... + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 && 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 && 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 && 1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 && 1 ))' + + # atf_expect_fail "PR bin/50960" + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x1111 && 01234 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0xFFFF && 0xF0F0 ))' +} +atf_test_case logical_or +logical_or_head() +{ + atf_set "descr" "Test logical or operations in arithmetic expressions" +} +logical_or_body() +{ + # cannot test short-circuit eval until sh implements side effects... + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 || 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 || 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 || 1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 || 1 ))' + + # atf_expect_fail "PR bin/50960" + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x1111 || 01234 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x33 || 0xF0F0 ))' +} + +atf_test_case make_selection +make_selection_head() +{ + atf_set "descr" "Test ?: operator in arithmetic expressions" +} +make_selection_body() +{ + # atf_expect_fail "PR bin/50958" + + atf_check -s exit:0 -o inline:'3\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0 ? 2 : 3 ))' + atf_check -s exit:0 -o inline:'2\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 ? 2 : 3 ))' + + atf_check -s exit:0 -o inline:'111\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0x1234 ? 111 : 222 ))' + + atf_check -s exit:0 -o inline:'-1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 < 2 ? -1 : 1 > 2 ? 1 : 0 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 < 1 ? -1 : 1 > 1 ? 1 : 0 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2 < 1 ? -1 : 2 > 1 ? 1 : 0 ))' +} + +atf_test_case operator_precedence +operator_precedence_head() +{ + atf_set "descr" "Test operator precedence without parentheses" +} +operator_precedence_body() +{ + # NB: apart from $(( )) ** NO ** parentheses in the expressions. + + atf_check -s exit:0 -o inline:'6\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 + 2 + 3 ))' + atf_check -s exit:0 -o inline:'2\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 - 2 + 3 ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 - 2 - 1 ))' + atf_check -s exit:0 -o inline:'2\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 - 2 + 1 ))' + + atf_check -s exit:0 -o inline:'-1\n' -e empty ${TEST_SH} -c \ + 'echo $(( - 2 + 1 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2 + -1 ))' + + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( ! 2 + 1 ))' + atf_check -s exit:0 -o inline:'2\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2 + !1 ))' + + atf_check -s exit:0 -o inline:'8\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 * 2 + 2 ))' + atf_check -s exit:0 -o inline:'7\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 + 2 * 2 ))' + atf_check -s exit:0 -o inline:'12\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 * 2 * 2 ))' + + atf_check -s exit:0 -o inline:'5\n' -e empty ${TEST_SH} -c \ + 'echo $(( 9 / 3 + 2 ))' + atf_check -s exit:0 -o inline:'10\n' -e empty ${TEST_SH} -c \ + 'echo $(( 9 + 3 / 2 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 9 / 3 / 2 ))' + + atf_check -s exit:0 -o inline:'72\n' -e empty ${TEST_SH} -c \ + 'echo $(( 9 << 1 + 2 ))' + atf_check -s exit:0 -o inline:'48\n' -e empty ${TEST_SH} -c \ + 'echo $(( 9 + 3 << 2 ))' + atf_check -s exit:0 -o inline:'288\n' -e empty ${TEST_SH} -c \ + 'echo $(( 9 << 3 << 2 ))' + + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 9 >> 1 + 2 ))' + atf_check -s exit:0 -o inline:'3\n' -e empty ${TEST_SH} -c \ + 'echo $(( 9 + 3 >> 2 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 19 >> 3 >> 1 ))' + + atf_check -s exit:0 -o inline:'4\n' -e empty ${TEST_SH} -c \ + 'echo $(( 19 >> 3 << 1 ))' + atf_check -s exit:0 -o inline:'76\n' -e empty ${TEST_SH} -c \ + 'echo $(( 19 << 3 >> 1 ))' + + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2 + 3 < 3 * 2 ))' + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2 << 3 >= 3 << 2 ))' + + # sh inherits C's crazy operator precedence... + + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 0xfD & 0xF == 0xF ))' +} + +parentheses_head() +{ + atf_set "descr" "Test use of () to group sub-expressions" +} +parentheses_body() +{ + atf_check -s exit:0 -o inline:'6\n' -e empty ${TEST_SH} -c \ + 'echo $(( (1 + 2) + 3 ))' + atf_check -s exit:0 -o inline:'-4\n' -e empty ${TEST_SH} -c \ + 'echo $(( 1 - (2 + 3) ))' + atf_check -s exit:0 -o inline:'2\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 - (2 - 1) ))' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 - ( 2 + 1 ) ))' + + atf_check -s exit:0 -o inline:'-3\n' -e empty ${TEST_SH} -c \ + 'echo $(( - (2 + 1) ))' + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( ! (2 + 1) ))' + + atf_check -s exit:0 -o inline:'12\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 * (2 + 2) ))' + atf_check -s exit:0 -o inline:'10\n' -e empty ${TEST_SH} -c \ + 'echo $(( (3 + 2) * 2 ))' + atf_check -s exit:0 -o inline:'12\n' -e empty ${TEST_SH} -c \ + 'echo $(( 3 * (2 * 2) ))' + + atf_check -s exit:0 -o inline:'1\n' -e empty ${TEST_SH} -c \ + 'echo $(( 9 / (3 + 2) ))' + atf_check -s exit:0 -o inline:'6\n' -e empty ${TEST_SH} -c \ + 'echo $(( ( 9 + 3 ) / 2 ))' + atf_check -s exit:0 -o inline:'9\n' -e empty ${TEST_SH} -c \ + 'echo $(( 9 / ( 3 / 2 ) ))' + + atf_check -s exit:0 -o inline:'20\n' -e empty ${TEST_SH} -c \ + 'echo $(( ( 9 << 1 ) + 2 ))' + atf_check -s exit:0 -o inline:'21\n' -e empty ${TEST_SH} -c \ + 'echo $(( 9 + (3 << 2) ))' + atf_check -s exit:0 -o inline:'36864\n' -e empty ${TEST_SH} -c \ + 'echo $(( 9 << (3 << 2) ))' + + atf_check -s exit:0 -o inline:'6\n' -e empty ${TEST_SH} -c \ + 'echo $(( (9 >> 1) + 2 ))' + atf_check -s exit:0 -o inline:'9\n' -e empty ${TEST_SH} -c \ + 'echo $(( 9 + (3 >> 2) ))' + atf_check -s exit:0 -o inline:'9\n' -e empty ${TEST_SH} -c \ + 'echo $(( 19 >> (3 >> 1) ))' + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( 19 >> (3 << 1) ))' + atf_check -s exit:0 -o inline:'38\n' -e empty ${TEST_SH} -c \ + 'echo $(( 19 << (3 >> 1) ))' + + atf_check -s exit:0 -o inline:'2\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2 + (3 < 3) * 2 ))' + atf_check -s exit:0 -o inline:'32\n' -e empty ${TEST_SH} -c \ + 'echo $(( 2 << ((3 >= 3) << 2) ))' + + # sh inherits C's crazy operator precedence... + + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'echo $(( (0xfD & 0xF) == 0xF ))' +} + +atf_test_case arithmetic_fails +arithmetic_fails_head() +{ + atf_set "descr" "Dummy test to force failure" +} +arithmetic_fails_body() +{ + atf_fail "Cannot estimate number of bits supported by $(( ))" +} + +atf_init_test_cases() { + + discover_range + + test "${ARITH_BITS}" = '?' && { + atf_add_test_case arithmetic_fails + return 0 + } + + # odd names are to get atf's sort order semi-rational + + atf_add_test_case constants + atf_add_test_case do_unary_plus + atf_add_test_case do_unary_minus + atf_add_test_case do_unary_not + atf_add_test_case do_unary_tilde + atf_add_test_case elementary_add + atf_add_test_case elementary_sub + atf_add_test_case elementary_mul + atf_add_test_case elementary_div + atf_add_test_case elementary_rem + atf_add_test_case elementary_shl + atf_add_test_case elementary_shr + atf_add_test_case elementary_eq + atf_add_test_case elementary_ne + atf_add_test_case elementary_lt + atf_add_test_case elementary_le + atf_add_test_case elementary_gt + atf_add_test_case elementary_ge + atf_add_test_case fiddle_bits_and + atf_add_test_case fiddle_bits_or + atf_add_test_case fiddle_bits_xor + atf_add_test_case logical_and + atf_add_test_case logical_or + atf_add_test_case make_selection + atf_add_test_case operator_precedence + atf_add_test_case parentheses + # atf_add_test_case progressive # build up big expr + # atf_add_test_case test_errors # erroneous input + # atf_add_test_case torture # hard stuff (if there is any) + # atf_add_test_case var_assign # assignment ops + # atf_add_test_case vulgarity # truly evil inputs (syntax in vars...) +} diff --git a/contrib/netbsd-tests/bin/sh/t_cmdsub.sh b/contrib/netbsd-tests/bin/sh/t_cmdsub.sh new file mode 100755 index 0000000..f3ee210 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_cmdsub.sh @@ -0,0 +1,783 @@ +# $NetBSD: t_cmdsub.sh,v 1.4 2016/04/04 12:40:13 christos Exp $ +# +# Copyright (c) 2016 The NetBSD Foundation, Inc. +# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# +# the implementation of "sh" to test +: ${TEST_SH:="/bin/sh"} + +# +# This file tests command substitutions ( `...` and $( ... ) ) +# +# CAUTION: +# Be careful attempting running these tests outside the ATF environment +# Some of the tests run "rm *" in the current directory to clean up +# An ATF test directory should be empty already, outside ATF, anything + +atf_test_case a_basic_cmdsub +a_basic_cmdsub_head() { + atf_set "descr" 'Test operation of simple $( ) substitutions' +} +a_basic_cmdsub_body() { + atf_check -s exit:0 -o match:'Result is true today' -e empty \ + ${TEST_SH} -c \ + 'echo Result is $( true && echo true || echo false ) today' + + atf_check -s exit:0 -o match:'Result is false today' -e empty \ + ${TEST_SH} -c \ + 'echo Result is $( false && echo true || echo false ) today' + + atf_check -s exit:0 -o match:'aaabbbccc' -e empty \ + ${TEST_SH} -c 'echo aaa$( echo bbb )ccc' + atf_check -s exit:0 -o match:'aaabbb cccddd' -e empty \ + ${TEST_SH} -c 'echo aaa$( echo bbb ccc )ddd' + atf_check -s exit:0 -o inline:'aaabbb cccddd\n' -e empty \ + ${TEST_SH} -c 'echo aaa$( echo bbb; echo ccc )ddd' + atf_check -s exit:0 -o inline:'aaabbb\ncccddd\n' -e empty \ + ${TEST_SH} -c 'echo "aaa$( echo bbb; echo ccc )ddd"' + + atf_check -s exit:0 -o inline:'some string\n' -e empty \ + ${TEST_SH} -c 'X=$( echo some string ); echo "$X"' + atf_check -s exit:0 -o inline:'weird; string *\n' -e empty \ + ${TEST_SH} -c 'X=$( echo "weird; string *" ); echo "$X"' + + rm -f * 2>/dev/null || : + for f in file-1 file-2 + do + cp /dev/null "$f" + done + + atf_check -s exit:0 -o match:'Found file-1 file-2' -e empty \ + ${TEST_SH} -c 'echo Found $( echo * )' + atf_check -s exit:0 -o match:'Found file-1 file-2' -e empty \ + ${TEST_SH} -c 'echo Found "$( echo * )"' + atf_check -s exit:0 -o match:'Found file-1 file-2' -e empty \ + ${TEST_SH} -c 'echo Found $('" echo '*' )" + atf_check -s exit:0 -o match:'Found \*' -e empty \ + ${TEST_SH} -c 'echo Found "$('" echo '*' "')"' + atf_check -s exit:0 -o match:'Found file-1 file-2' -e empty \ + ${TEST_SH} -c 'echo Found $('" echo \\* )" + atf_check -s exit:0 -o match:'Found \*' -e empty \ + ${TEST_SH} -c 'echo Found "$('" echo \\* )"\" +} + +atf_test_case b_basic_backticks +b_basic_backticks_head() { + atf_set "descr" 'Test operation of old style ` ` substitutions' +} +b_basic_backticks_body() { + atf_check -s exit:0 -o match:'Result is true today' -e empty \ + ${TEST_SH} -c \ + 'echo Result is `true && echo true || echo false` today' + + atf_check -s exit:0 -o match:'Result is false today' -e empty \ + ${TEST_SH} -c \ + 'echo Result is `false && echo true || echo false` today' + + atf_check -s exit:0 -o match:'aaabbbccc' -e empty \ + ${TEST_SH} -c 'echo aaa` echo bbb `ccc' + atf_check -s exit:0 -o match:'aaabbb cccddd' -e empty \ + ${TEST_SH} -c 'echo aaa` echo bbb ccc `ddd' + atf_check -s exit:0 -o inline:'aaabbb cccddd\n' -e empty \ + ${TEST_SH} -c 'echo aaa` echo bbb; echo ccc `ddd' + atf_check -s exit:0 -o inline:'aaabbb\ncccddd\n' -e empty \ + ${TEST_SH} -c 'echo "aaa` echo bbb; echo ccc `ddd"' + + atf_check -s exit:0 -o inline:'some string\n' -e empty \ + ${TEST_SH} -c 'X=` echo some string `; echo "$X"' + atf_check -s exit:0 -o inline:'weird; string *\n' -e empty \ + ${TEST_SH} -c 'X=` echo "weird; string *" `; echo "$X"' + + rm -f * 2>/dev/null || : + for f in file-1 file-2 + do + cp /dev/null "$f" + done + + atf_check -s exit:0 -o match:'Found file-1 file-2' -e empty \ + ${TEST_SH} -c 'echo Found ` echo * `' + atf_check -s exit:0 -o match:'Found file-1 file-2' -e empty \ + ${TEST_SH} -c 'echo Found "` echo * `"' + atf_check -s exit:0 -o match:'Found file-1 file-2' -e empty \ + ${TEST_SH} -c 'echo Found `'" echo '*' "'`' + atf_check -s exit:0 -o match:'Found \*' -e empty \ + ${TEST_SH} -c 'echo Found "`'" echo '*' "'`"' + atf_check -s exit:0 -o match:'Found file-1 file-2' -e empty \ + ${TEST_SH} -c 'echo Found `'" echo \\* "'`' + atf_check -s exit:0 -o match:'Found \*' -e empty \ + ${TEST_SH} -c 'echo Found "`'" echo \\* "'`"' +} + +atf_test_case c_nested_cmdsub +c_nested_cmdsub_head() { + atf_set "descr" "Test that cmd substitutions can be nested" +} +c_nested_cmdsub_body() { + atf_check -s exit:0 -o match:'__foobarbletch__' -e empty \ + ${TEST_SH} -c 'echo __$( echo foo$(echo bar)bletch )__' + atf_check -s exit:0 -o match:'_abcde_' -e empty \ + ${TEST_SH} -c 'echo _$(echo a$(echo $(echo b)c$(echo d))e )_' + atf_check -s exit:0 -o match:'123454321' -e empty \ + ${TEST_SH} -c 'echo 1$(echo 2$(echo 3$(echo 4$(echo 5)4)3)2)1' +} + +atf_test_case d_nested_backticks +d_nested_backticks_head() { + atf_set "descr" "Tests that old style backtick cmd subs can be nested" +} +d_nested_backticks_body() { + atf_check -s exit:0 -o match:'__foobarbletch__' -e empty \ + ${TEST_SH} -c 'echo __` echo foo\`echo bar\`bletch `__' + atf_check -s exit:0 -o match:'_abcde_' -e empty \ + ${TEST_SH} -c \ + 'echo _`echo a\`echo \\\`echo b\\\`c\\\`echo d\\\`\`e `_' + atf_check -s exit:0 -o match:'123454321' -e empty \ + ${TEST_SH} -c \ + 'echo 1`echo 2\`echo 3\\\`echo 4\\\\\\\`echo 5\\\\\\\`4\\\`3\`2`1' +} + +atf_test_case e_perverse_mixing +e_perverse_mixing_head() { + atf_set "descr" \ + "Checks various mixed new and old style cmd substitutions" +} +e_perverse_mixing_body() { + atf_check -s exit:0 -o match:'__foobarbletch__' -e empty \ + ${TEST_SH} -c 'echo __$( echo foo`echo bar`bletch )__' + atf_check -s exit:0 -o match:'__foobarbletch__' -e empty \ + ${TEST_SH} -c 'echo __` echo foo$(echo bar)bletch `__' + atf_check -s exit:0 -o match:'_abcde_' -e empty \ + ${TEST_SH} -c 'echo _$(echo a`echo $(echo b)c$(echo d)`e )_' + atf_check -s exit:0 -o match:'_abcde_' -e empty \ + ${TEST_SH} -c 'echo _`echo a$(echo \`echo b\`c\`echo d\`)e `_' + atf_check -s exit:0 -o match:'12345654321' -e empty \ + ${TEST_SH} -c \ + 'echo 1`echo 2$(echo 3\`echo 4\\\`echo 5$(echo 6)5\\\`4\`3)2`1' +} + +atf_test_case f_redirect_in_cmdsub +f_redirect_in_cmdsub_head() { + atf_set "descr" "Checks that redirects work in command substitutions" +} +f_redirect_in_cmdsub_body() { + atf_require_prog cat + atf_require_prog rm + + rm -f file 2>/dev/null || : + atf_check -s exit:0 -o match:'_aa_' -e empty \ + ${TEST_SH} -c 'echo _$( echo a$( echo b > file )a)_' + atf_check -s exit:0 -o match:b -e empty ${TEST_SH} -c 'cat file' + atf_check -s exit:0 -o match:'_aba_' -e empty \ + ${TEST_SH} -c 'echo _$( echo a$( cat < file )a)_' + atf_check -s exit:0 -o match:'_aa_' -e empty \ + ${TEST_SH} -c 'echo _$( echo a$( echo d >> file )a)_' + atf_check -s exit:0 -o inline:'b\nd\n' -e empty ${TEST_SH} -c 'cat file' + atf_check -s exit:0 -o match:'_aa_' -e match:'not error' \ + ${TEST_SH} -c 'echo _$( echo a$( echo not error >&2 )a)_' +} + +atf_test_case g_redirect_in_backticks +g_redirect_in_backticks_head() { + atf_set "descr" "Checks that redirects work in old style cmd sub" +} +g_redirect_in_backticks_body() { + atf_require_prog cat + atf_require_prog rm + + rm -f file 2>/dev/null || : + atf_check -s exit:0 -o match:'_aa_' -e empty \ + ${TEST_SH} -c 'echo _` echo a\` echo b > file \`a`_' + atf_check -s exit:0 -o match:b -e empty ${TEST_SH} -c 'cat file' + atf_check -s exit:0 -o match:'_aba_' -e empty \ + ${TEST_SH} -c 'echo _` echo a\` cat < file \`a`_' + atf_check -s exit:0 -o match:'_aa_' -e empty \ + ${TEST_SH} -c 'echo _` echo a\` echo d >> file \`a`_' + atf_check -s exit:0 -o inline:'b\nd\n' -e empty ${TEST_SH} -c 'cat file' + atf_check -s exit:0 -o match:'_aa_' -e match:'not error' \ + ${TEST_SH} -c 'echo _` echo a\` echo not error >&2 \`a`_' +} + +atf_test_case h_vars_in_cmdsub +h_vars_in_cmdsub_head() { + atf_set "descr" "Check that variables work in command substitutions" +} +h_vars_in_cmdsub_body() { + atf_check -s exit:0 -o match:'__abc__' -e empty \ + ${TEST_SH} -c 'X=abc; echo __$( echo ${X} )__' + atf_check -s exit:0 -o match:'__abc__' -e empty \ + ${TEST_SH} -c 'X=abc; echo __$( echo "${X}" )__' + atf_check -s exit:0 -o match:'__abc__' -e empty \ + ${TEST_SH} -c 'X=abc; echo "__$( echo ${X} )__"' + atf_check -s exit:0 -o match:'__abc__' -e empty \ + ${TEST_SH} -c 'X=abc; echo "__$( echo "${X}" )__"' + + atf_check -s exit:0 -o inline:'a\n\nb\n\nc\n' -e empty \ + ${TEST_SH} -c "for X in a '' b '' c"'; do echo $( echo "$X" ); done' + + atf_check -s exit:0 -o match:'__acd__' -e empty \ + ${TEST_SH} -c 'X=; unset Y; echo "__$( echo a${X-b}${Y-c}d)__"' + atf_check -s exit:0 -o match:'__abcd__' -e empty \ + ${TEST_SH} -c 'X=; unset Y; echo "__$( echo a${X:-b}${Y:-c}d)__"' + atf_check -s exit:0 -o match:'__XYX__' -e empty \ + ${TEST_SH} -c 'X=X; echo "__${X}$( X=Y; echo ${X} )${X}__"' + atf_check -s exit:0 -o match:'__def__' -e empty \ + ${TEST_SH} -c 'X=abc; echo "__$(X=def; echo "${X}" )__"' + atf_check -s exit:0 -o inline:'abcdef\nabc\n' -e empty \ + ${TEST_SH} -c 'X=abc; echo "$X$(X=def; echo ${X} )"; echo $X' +} + +atf_test_case i_vars_in_backticks +i_vars_in_backticks_head() { + atf_set "descr" "Checks that variables work in old style cmd sub" +} +i_vars_in_backticks_body() { + atf_check -s exit:0 -o match:'__abc__' -e empty \ + ${TEST_SH} -c 'X=abc; echo __` echo ${X} `__' + atf_check -s exit:0 -o match:'__abc__' -e empty \ + ${TEST_SH} -c 'X=abc; echo __` echo "${X}" `__' + atf_check -s exit:0 -o match:'__abc__' -e empty \ + ${TEST_SH} -c 'X=abc; echo "__` echo ${X} `__"' + atf_check -s exit:0 -o match:'__abc__' -e empty \ + ${TEST_SH} -c 'X=abc; echo "__` echo \"${X}\" `__"' + + atf_check -s exit:0 -o inline:'a\n\nb\n\nc\n' -e empty \ + ${TEST_SH} -c "for X in a '' b '' c"'; do echo $( echo "$X" ); done' + + atf_check -s exit:0 -o match:'__acd__' -e empty \ + ${TEST_SH} -c 'X=; unset Y; echo "__$( echo a${X-b}${Y-c}d)__"' + atf_check -s exit:0 -o match:'__abcd__' -e empty \ + ${TEST_SH} -c 'X=; unset Y; echo "__$( echo a${X:-b}${Y:-c}d)__"' + atf_check -s exit:0 -o match:'__XYX__' -e empty \ + ${TEST_SH} -c 'X=X; echo "__${X}$( X=Y; echo ${X} )${X}__"' + atf_check -s exit:0 -o inline:'abcdef\nabc\n' -e empty \ + ${TEST_SH} -c 'X=abc; echo "$X`X=def; echo \"${X}\" `";echo $X' + + # The following is nonsense, so is not included ... + # atf_check -s exit:0 -o match:'__abc__' -e empty \ + # oV cV oV cV + # ${TEST_SH} -c 'X=abc; echo "__`X=def echo "${X}" `__"' + # `start in " ^ " ends, ` not yet +} + +atf_test_case j_cmdsub_in_varexpand +j_cmdsub_in_varexpand_head() { + atf_set "descr" "Checks that command sub can be used in var expansion" +} +j_cmdsub_in_varexpand_body() { + atf_check -s exit:0 -o match:'foo' -e empty \ + ${TEST_SH} -c 'X=set; echo ${X+$(echo foo)}' + atf_check -s exit:0 -o match:'set' -e empty \ + ${TEST_SH} -c 'X=set; echo ${X-$(echo foo)}' + rm -f bar 2>/dev/null || : + atf_check -s exit:0 -o match:'set' -e empty \ + ${TEST_SH} -c 'X=set; echo ${X-$(echo foo > bar)}' + test -f bar && atf_fail "bar should not exist, but does" + atf_check -s exit:0 -o inline:'\n' -e empty \ + ${TEST_SH} -c 'X=set; echo ${X+$(echo foo > bar)}' + test -f bar || atf_fail "bar should exist, but does not" +} + +atf_test_case k_backticks_in_varexpand +k_backticks_in_varexpand_head() { + atf_set "descr" "Checks that old style cmd sub works in var expansion" +} +k_backticks_in_varexpand_body() { + atf_check -s exit:0 -o match:'foo' -e empty \ + ${TEST_SH} -c 'X=set; echo ${X+`echo foo`}' + atf_check -s exit:0 -o match:'set' -e empty \ + ${TEST_SH} -c 'X=set; echo ${X-`echo foo`}' + rm -f bar 2>/dev/null || : + atf_check -s exit:0 -o match:'set' -e empty \ + ${TEST_SH} -c 'X=set; echo ${X-`echo foo > bar`}' + test -f bar && atf_fail "bar should not exist, but does" + atf_check -s exit:0 -o inline:'\n' -e empty \ + ${TEST_SH} -c 'X=set; echo ${X+`echo foo > bar`}' + test -f bar || atf_fail "bar should exist, but does not" +} + +atf_test_case l_arithmetic_in_cmdsub +l_arithmetic_in_cmdsub_head() { + atf_set "descr" "Checks that arithmetic works in cmd substitutions" +} +l_arithmetic_in_cmdsub_body() { + atf_check -s exit:0 -o inline:'1 + 1 = 2\n' -e empty \ + ${TEST_SH} -c 'echo 1 + 1 = $( echo $(( 1 + 1 )) )' + atf_check -s exit:0 -o inline:'X * Y = 6\n' -e empty \ + ${TEST_SH} -c 'X=2; Y=3; echo X \* Y = $( echo $(( X * Y )) )' + atf_check -s exit:0 -o inline:'Y % X = 1\n' -e empty \ + ${TEST_SH} -c 'X=2; Y=3; echo Y % X = $( echo $(( $Y % $X )) )' +} + +atf_test_case m_arithmetic_in_backticks +m_arithmetic_in_backticks_head() { + atf_set "descr" "Checks that arithmetic works in old style cmd sub" +} +m_arithmetic_in_backticks_body() { + atf_check -s exit:0 -o inline:'2 + 3 = 5\n' -e empty \ + ${TEST_SH} -c 'echo 2 + 3 = ` echo $(( 2 + 3 )) `' + atf_check -s exit:0 -o inline:'X * Y = 6\n' -e empty \ + ${TEST_SH} -c 'X=2; Y=3; echo X \* Y = ` echo $(( X * Y )) `' + atf_check -s exit:0 -o inline:'Y % X = 1\n' -e empty \ + ${TEST_SH} -c 'X=2; Y=3; echo Y % X = ` echo $(( $Y % $X )) `' +} + +atf_test_case n_cmdsub_in_arithmetic +n_cmdsub_in_arithmetic_head() { + atf_set "descr" "Tests uses of command substitutions in arithmetic" +} +n_cmdsub_in_arithmetic_body() { + atf_check -s exit:0 -o inline:'7\n' -e empty \ + ${TEST_SH} -c 'echo $(( $( echo 3 ) $( echo + ) $( echo 4 ) ))' + atf_check -s exit:0 -o inline:'11\n7\n18\n4\n1\n' -e empty \ + ${TEST_SH} -c \ + 'for op in + - \* / % + do + echo $(( $( echo 9 ) $( echo "${op}" ) $( echo 2 ) )) + done' +} + +atf_test_case o_backticks_in_arithmetic +o_backticks_in_arithmetic_head() { + atf_set "descr" "Tests old style cmd sub used in arithmetic" +} +o_backticks_in_arithmetic_body() { + atf_check -s exit:0 -o inline:'33\n' -e empty \ + ${TEST_SH} -c 'echo $(( `echo 77` `echo -` `echo 44`))' + atf_check -s exit:0 -o inline:'14\n8\n33\n3\n2\n' -e empty \ + ${TEST_SH} -c \ + 'for op in + - \* / % + do + echo $((`echo 11``echo "${op}"``echo 3`)) + done' +} + +atf_test_case p_cmdsub_in_heredoc +p_cmdsub_in_heredoc_head() { + atf_set "descr" "Checks that cmdsubs work inside a here document" +} +p_cmdsub_in_heredoc_body() { + atf_require_prog cat + + atf_check -s exit:0 -o inline:'line 1+1\nline 2\nline 3\n' -e empty \ + ${TEST_SH} -c \ + 'cat <<- EOF + $( echo line 1 )$( echo +1 ) + $( echo line 2;echo line 3 ) + EOF' +} + +atf_test_case q_backticks_in_heredoc +q_backticks_in_heredoc_head() { + atf_set "descr" "Checks that old style cmdsubs work in here docs" +} +q_backticks_in_heredoc_body() { + atf_require_prog cat + + atf_check -s exit:0 -o inline:'Mary had a\nlittle\nlamb\n' -e empty \ + ${TEST_SH} -c \ + 'cat <<- EOF + `echo Mary ` `echo had a ` + ` echo little; echo lamb ` + EOF' +} + +atf_test_case r_heredoc_in_cmdsub +r_heredoc_in_cmdsub_head() { + atf_set "descr" "Checks that here docs work inside cmd subs" +} +r_heredoc_in_cmdsub_body() { + atf_require_prog cat + + atf_check -s exit:0 -o inline:'Mary had a\nlittle\nlamb\n' -e empty \ + ${TEST_SH} -c 'echo "$( cat <<- \EOF + Mary had a + little + lamb + EOF + )"' + + atf_check -s exit:0 -e empty \ + -o inline:'Mary had 1\nlittle\nlamb\nMary had 4\nlittle\nlambs\n' \ + ${TEST_SH} -c 'for N in 1 4; do echo "$( cat <<- EOF + Mary had ${N} + little + lamb$( [ $N -gt 1 ] && echo s ) + EOF + )"; done' + + + atf_check -s exit:0 -o inline:'A Calculation:\n2 * 7 = 14\n' -e empty \ + ${TEST_SH} -c 'echo "$( cat <<- EOF + A Calculation: + 2 * 7 = $(( 2 * 7 )) + EOF + )"' +} + +atf_test_case s_heredoc_in_backticks +s_heredoc_in_backticks_head() { + atf_set "descr" "Checks that here docs work inside old style cmd subs" +} +s_heredoc_in_backticks_body() { + atf_require_prog cat + + atf_check -s exit:0 -o inline:'Mary had a little lamb\n' -e empty \ + ${TEST_SH} -c 'echo ` cat <<- \EOF + Mary had a + little + lamb + EOF + `' + + atf_check -s exit:0 -o inline:'A Calculation:\n17 / 3 = 5\n' -e empty \ + ${TEST_SH} -c 'echo "` cat <<- EOF + A Calculation: + 17 / 3 = $(( 17 / 3 )) + EOF + `"' +} + +atf_test_case t_nested_cmdsubs_in_heredoc +t_nested_cmdsubs_in_heredoc_head() { + atf_set "descr" "Checks nested command substitutions in here docs" +} +t_nested_cmdsubs_in_heredoc_body() { + atf_require_prog cat + atf_require_prog rm + + rm -f * 2>/dev/null || : + echo "Hello" > File + + atf_check -s exit:0 -o inline:'Hello U\nHelp me!\n' -e empty \ + ${TEST_SH} -c 'cat <<- EOF + $(cat File) U + $( V=$(cat File); echo "${V%lo}p" ) me! + EOF' + + rm -f * 2>/dev/null || : + echo V>V ; echo A>A; echo R>R + echo Value>VAR + + atf_check -s exit:0 -o inline:'$2.50\n' -e empty \ + ${TEST_SH} -c 'cat <<- EOF + $(Value='\''$2.50'\'';eval echo $(eval $(cat V)$(cat A)$(cat R)=\'\''\$$(cat $(cat V)$(cat A)$(cat R))\'\''; eval echo \$$(set -- *;echo ${3}${1}${2}))) + EOF' +} + +atf_test_case u_nested_backticks_in_heredoc +u_nested_backticks_in_heredoc_head() { + atf_set "descr" "Checks nested old style cmd subs in here docs" +} +u_nested_backticks_in_heredoc_body() { + atf_require_prog cat + atf_require_prog rm + + rm -f * 2>/dev/null || : + echo "Hello" > File + + atf_check -s exit:0 -o inline:'Hello U\nHelp me!\n' -e empty \ + ${TEST_SH} -c 'cat <<- EOF + `cat File` U + `V=\`cat File\`; echo "${V%lo}p" ` me! + EOF' + + rm -f * 2>/dev/null || : + echo V>V ; echo A>A; echo R>R + echo Value>VAR + + atf_check -s exit:0 -o inline:'$5.20\n' -e empty \ + ${TEST_SH} -c 'cat <<- EOF + `Value='\''$5.20'\'';eval echo \`eval \\\`cat V\\\`\\\`cat A\\\`\\\`cat R\\\`=\\\'\''\\\$\\\`cat \\\\\\\`cat V\\\\\\\`\\\\\\\`cat A\\\\\\\`\\\\\\\`cat R\\\\\\\`\\\`\\\'\''; eval echo \\\$\\\`set -- *;echo \\\\\${3}\\\\\${1}\\\\\${2}\\\`\`` + EOF' +} + +atf_test_case v_cmdsub_paren_tests +v_cmdsub__paren_tests_head() { + atf_set "descr" "tests with cmdsubs containing embedded ')'" +} +v_cmdsub_paren_tests_body() { + + # Tests from: + # http://www.in-ulm.de/~mascheck/various/cmd-subst/ + # (slightly modified.) + + atf_check -s exit:0 -o inline:'A.1\n' -e empty ${TEST_SH} -c \ + 'echo $( + case x in x) echo A.1;; esac + )' + + atf_check -s exit:0 -o inline:'A.2\n' -e empty ${TEST_SH} -c \ + 'echo $( + case x in x) echo A.2;; esac # comment + )' + + atf_check -s exit:0 -o inline:'A.3\n' -e empty ${TEST_SH} -c \ + 'echo $( + case x in (x) echo A.3;; esac + )' + + atf_check -s exit:0 -o inline:'A.4\n' -e empty ${TEST_SH} -c \ + 'echo $( + case x in (x) echo A.4;; esac # comment + )' + + atf_check -s exit:0 -o inline:'A.5\n' -e empty ${TEST_SH} -c \ + 'echo $( + case x in (x) echo A.5 + esac + )' + + atf_check -s exit:0 -o inline:'B: quoted )\n' -e empty ${TEST_SH} -c \ + 'echo $( + echo '\''B: quoted )'\'' + )' + + atf_check -s exit:0 -o inline:'C: comment then closing paren\n' \ + -e empty ${TEST_SH} -c \ + 'echo $( + echo C: comment then closing paren # ) + )' + + atf_check -s exit:0 -o inline:'D.1: here-doc with )\n' \ + -e empty ${TEST_SH} -c \ + 'echo $( + cat <<-\eof + D.1: here-doc with ) + eof + )' + + # D.2 is a bogus test. + + atf_check -s exit:0 -o inline:'D.3: here-doc with \()\n' \ + -e empty ${TEST_SH} -c \ + 'echo $( + cat <<-\eof + D.3: here-doc with \() + eof + )' + + atf_check -s exit:0 -e empty \ + -o inline:'E: here-doc terminated with a parenthesis ("academic")\n' \ + ${TEST_SH} -c \ + 'echo $( + cat <<-\) + E: here-doc terminated with a parenthesis ("academic") + ) + )' + + atf_check -s exit:0 -e empty \ +-o inline:'F.1: here-doc embed with unbal single, back- or doublequote '\''\n' \ + ${TEST_SH} -c \ + 'echo $( + cat <<-"eof" + F.1: here-doc embed with unbal single, back- or doublequote '\'' + eof + )' + atf_check -s exit:0 -e empty \ + -o inline:'F.2: here-doc embed with unbal single, back- or doublequote "\n' \ + ${TEST_SH} -c \ + 'echo $( + cat <<-"eof" + F.2: here-doc embed with unbal single, back- or doublequote " + eof + )' + atf_check -s exit:0 -e empty \ + -o inline:'F.3: here-doc embed with unbal single, back- or doublequote `\n' \ + ${TEST_SH} -c \ + 'echo $( + cat <<-"eof" + F.3: here-doc embed with unbal single, back- or doublequote ` + eof + )' + + atf_check -s exit:0 -e empty -o inline:'G: backslash at end of line\n' \ + ${TEST_SH} -c \ + 'echo $( + echo G: backslash at end of line # \ + )' + + atf_check -s exit:0 -e empty \ + -o inline:'H: empty command-substitution\n' \ + ${TEST_SH} -c 'echo H: empty command-substitution $( )' +} + +atf_test_case w_heredoc_outside_cmdsub +w_heredoc_outside_cmdsub_head() { + atf_set "descr" "Checks that here docs work inside cmd subs" +} +w_heredoc_outside_cmdsub_body() { + atf_require_prog cat + + atf_check -s exit:0 -o inline:'Mary had a\nlittle\nlamb\n' -e empty \ + ${TEST_SH} -c 'echo "$( cat <<- \EOF )" + Mary had a + little + lamb + EOF + ' + + atf_check -s exit:0 -e empty \ + -o inline:'Mary had 1\nlittle\nlamb\nMary had 4\nlittle\nlambs\n' \ + ${TEST_SH} -c 'for N in 1 4; do echo "$( cat <<- EOF )" + Mary had ${N} + little + lamb$( [ $N -gt 1 ] && echo s ) + EOF + done' + + + atf_check -s exit:0 -o inline:'A Calculation:\n2 * 7 = 14\n' -e empty \ + ${TEST_SH} -c 'echo "$( cat <<- EOF)" + A Calculation: + 2 * 7 = $(( 2 * 7 )) + EOF + ' +} + +atf_test_case x_heredoc_outside_backticks +x_heredoc_outside_backticks_head() { + atf_set "descr" "Checks that here docs work inside old style cmd subs" +} +x_heredoc_outside_backticks_body() { + atf_require_prog cat + + atf_check -s exit:0 -o inline:'Mary had a little lamb\n' -e empty \ + ${TEST_SH} -c 'echo ` cat <<- \EOF ` + Mary had a + little + lamb + EOF + ' + + atf_check -s exit:0 -o inline:'A Calculation:\n17 / 3 = 5\n' -e empty \ + ${TEST_SH} -c 'echo "` cat <<- EOF `" + A Calculation: + 17 / 3 = $(( 17 / 3 )) + EOF + ' +} + +atf_test_case t_nested_cmdsubs_in_heredoc +t_nested_cmdsubs_in_heredoc_head() { + atf_set "descr" "Checks nested command substitutions in here docs" +} +t_nested_cmdsubs_in_heredoc_body() { + atf_require_prog cat + atf_require_prog rm + + rm -f * 2>/dev/null || : + echo "Hello" > File + + atf_check -s exit:0 -o inline:'Hello U\nHelp me!\n' -e empty \ + ${TEST_SH} -c 'cat <<- EOF + $(cat File) U + $( V=$(cat File); echo "${V%lo}p" ) me! + EOF' + + rm -f * 2>/dev/null || : + echo V>V ; echo A>A; echo R>R + echo Value>VAR + + atf_check -s exit:0 -o inline:'$2.50\n' -e empty \ + ${TEST_SH} -c 'cat <<- EOF + $(Value='\''$2.50'\'';eval echo $(eval $(cat V)$(cat A)$(cat R)=\'\''\$$(cat $(cat V)$(cat A)$(cat R))\'\''; eval echo \$$(set -- *;echo ${3}${1}${2}))) + EOF' +} + +atf_test_case z_absurd_heredoc_cmdsub_combos +z_absurd_heredoc_cmdsub_combos_head() { + atf_set "descr" "perverse and unusual cmd substitutions & more" +} +z_absurd_heredoc_cmdsub_combos_body() { + + echo "Help!" > help + + # This version works in NetBSD (& FreeBSD)'s sh (and most others) + atf_check -s exit:0 -o inline:'Help!\nMe 2\n' -e empty ${TEST_SH} -c ' + cat <<- EOF + $( + cat <<- STOP + $( + cat `echo help` + ) + STOP + ) + $( + cat <<- END 4<<-TRASH + Me $(( 1 + 1 )) + END + This is unused noise! + TRASH + ) + EOF + ' + + # atf_expect_fail "PR bin/50993 - heredoc parsing done incorrectly" + atf_check -s exit:0 -o inline:'Help!\nMe 2\n' -e empty ${TEST_SH} -c ' + cat <<- EOF + $( + cat << STOP + $( + cat `echo help` + ) + STOP + ) + $( + cat <<- END 4<0, and is not part of the compound list following a -# while, until, or if keyword, and is not a part of an AND or OR list, -# and is not a pipeline preceded by the ! reserved word, then the shell -# shall immediately exit. - -crud() { - set -e - for x in a - do - BAR="foo" - false && echo true - echo mumble - done -} - -atf_test_case set_e -set_e_head() { - atf_set "descr" "Tests that 'set -e' turns on error detection" \ - "and that it behaves as defined by the standard" -} -set_e_body() { - foo=`crud` - atf_check_equal 'x$foo' 'xmumble' -} - -atf_init_test_cases() { - atf_add_test_case set_e -} diff --git a/contrib/netbsd-tests/bin/sh/t_evaltested.sh b/contrib/netbsd-tests/bin/sh/t_evaltested.sh index e40f8bd..128a55c 100755 --- a/contrib/netbsd-tests/bin/sh/t_evaltested.sh +++ b/contrib/netbsd-tests/bin/sh/t_evaltested.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_evaltested.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# $NetBSD: t_evaltested.sh,v 1.2 2016/03/27 14:50:01 christos Exp $ # # Copyright (c) 2011 The NetBSD Foundation, Inc. # All rights reserved. @@ -24,6 +24,8 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # +# the implementation of "sh" to test +: ${TEST_SH:="/bin/sh"} atf_test_case evaltested @@ -43,7 +45,7 @@ fi echo "passed" exit 0 EOF - output="$(/bin/sh helper.sh)" + output="$($TEST_SH helper.sh)" [ $? = 0 ] && return if [ -n "$output" ] diff --git a/contrib/netbsd-tests/bin/sh/t_exit.sh b/contrib/netbsd-tests/bin/sh/t_exit.sh index 62c5869..17ed230 100755 --- a/contrib/netbsd-tests/bin/sh/t_exit.sh +++ b/contrib/netbsd-tests/bin/sh/t_exit.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_exit.sh,v 1.3 2012/04/13 06:12:32 jruoho Exp $ +# $NetBSD: t_exit.sh,v 1.6 2016/05/07 23:51:30 kre Exp $ # # Copyright (c) 2007 The NetBSD Foundation, Inc. # All rights reserved. @@ -24,74 +24,124 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # +# the implementation of "sh" to test +: ${TEST_SH:="/bin/sh"} -crud() { - test yes = no - - cat <helper.sh - atf_check -s eq:0 -o match:exiting -e empty /bin/sh helper.sh - atf_check -s eq:0 -o match:exiting -e empty /bin/ksh helper.sh + atf_check -s exit:0 -o match:exiting -e empty ${TEST_SH} helper.sh + # test ksh by setting TEST_SH to /bin/ksh and run the entire set... + # atf_check -s exit:0 -o match:exiting -e empty /bin/ksh helper.sh } atf_test_case trap_zero__explicit_exit +trap_zero__explicit_exit_head() { + atf_set "descr" "Tests that the trap statement in a subshell in a " \ + "script works when the subshell executes an explicit exit" +} trap_zero__explicit_exit_body() { - echo '( trap "echo exiting" 0; exit )' >helper.sh - atf_check -s eq:0 -o match:exiting -e empty /bin/sh helper.sh - atf_check -s eq:0 -o match:exiting -e empty /bin/ksh helper.sh + echo '( trap "echo exiting" 0; exit; echo NO_NO_NO )' >helper.sh + atf_check -s exit:0 -o match:exiting -o not-match:NO_NO -e empty \ + ${TEST_SH} helper.sh + # test ksh by setting TEST_SH to /bin/ksh and run the entire set... + # atf_check -s exit:0 -o match:exiting -e empty /bin/ksh helper.sh } -atf_test_case trap_zero__explicit_return -trap_zero__explicit_return_body() { - echo '( trap "echo exiting" 0; return )' >helper.sh - atf_check -s eq:0 -o match:exiting -e empty /bin/sh helper.sh - atf_check -s eq:0 -o match:exiting -e empty /bin/ksh helper.sh +atf_test_case simple_exit +simple_exit_head() { + atf_set "descr" "Tests that various values for exit status work" +} +# Note: ATF will not allow tests of exit values > 255, even if they would work +simple_exit_body() { + for N in 0 1 2 3 4 5 6 42 99 101 125 126 127 128 129 200 254 255 + do + atf_check -s exit:$N -o empty -e empty \ + ${TEST_SH} -c "exit $N; echo FOO; echo BAR >&2" + done +} + +atf_test_case subshell_exit +subshell_exit_head() { + atf_set "descr" "Tests that subshell exit status works and \$? gets it" +} +# Note: ATF will not allow tests of exit values > 255, even if they would work +subshell_exit_body() { + for N in 0 1 2 3 4 5 6 42 99 101 125 126 127 128 129 200 254 255 + do + atf_check -s exit:0 -o empty -e empty \ + ${TEST_SH} -c "(exit $N); test \$? -eq $N" + done +} + +atf_test_case subshell_background +subshell_background_head() { + atf_set "descr" "Tests that sh(1) sets '$?' properly when running " \ + "a subshell in the background" +} +subshell_background_body() { + atf_check -o match:0 -e empty \ + ${TEST_SH} -c 'true; (false || true) & echo $?' + # atf_expect_fail "PR bin/46327" (now fixed?) + atf_check -o match:0 -e empty \ + ${TEST_SH} -c 'false; (false || true) & echo $?' } atf_init_test_cases() { @@ -101,5 +151,7 @@ atf_init_test_cases() { atf_add_test_case trap_subshell atf_add_test_case trap_zero__implicit_exit atf_add_test_case trap_zero__explicit_exit - atf_add_test_case trap_zero__explicit_return + atf_add_test_case simple_exit + atf_add_test_case subshell_exit + atf_add_test_case subshell_background } diff --git a/contrib/netbsd-tests/bin/sh/t_expand.sh b/contrib/netbsd-tests/bin/sh/t_expand.sh index eeaad5f..e785e1f 100755 --- a/contrib/netbsd-tests/bin/sh/t_expand.sh +++ b/contrib/netbsd-tests/bin/sh/t_expand.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_expand.sh,v 1.2 2013/10/06 21:05:50 ast Exp $ +# $NetBSD: t_expand.sh,v 1.8 2016/04/29 18:29:17 christos Exp $ # # Copyright (c) 2007, 2009 The NetBSD Foundation, Inc. # All rights reserved. @@ -24,6 +24,8 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # +# the implementation of "sh" to test +: ${TEST_SH:="/bin/sh"} # # This file tests the functions in expand.c. @@ -50,19 +52,15 @@ dollar_at_head() { } dollar_at_body() { # This one should work everywhere. - got=`echo "" "" | sed 's,$,EOL,'` - atf_check_equal ' EOL' '$got' + atf_check -s exit:0 -o inline:' EOL\n' -e empty \ + ${TEST_SH} -c 'echo "" "" | '" sed 's,\$,EOL,'" # This code triggered the bug. - set -- "" "" - got=`echo "$@" | sed 's,$,EOL,'` - atf_check_equal ' EOL' '$got' + atf_check -s exit:0 -o inline:' EOL\n' -e empty \ + ${TEST_SH} -c 'set -- "" ""; echo "$@" | '" sed 's,\$,EOL,'" - set -- - - shift - n_arg() { echo $#; } - n_args=`n_arg "$@"` - atf_check_equal '0' '$n_args' + atf_check -s exit:0 -o inline:'0\n' -e empty ${TEST_SH} -c \ + 'set -- -; shift; n_arg() { echo $#; }; n_arg "$@"' } atf_test_case dollar_at_with_text @@ -71,15 +69,61 @@ dollar_at_with_text_head() { "within the quotes. PR bin/33956." } dollar_at_with_text_body() { - set -- - atf_check_equal '' "$(delim_argv "$@")" - atf_check_equal '>foobar<' "$(delim_argv "foo$@bar")" - atf_check_equal '>foo bar<' "$(delim_argv "foo $@ bar")" - set -- a b c - atf_check_equal '>a< >b< >c<' "$(delim_argv "$@")" - atf_check_equal '>fooa< >b< >cbar<' "$(delim_argv "foo$@bar")" - atf_check_equal '>foo a< >b< >c bar<' "$(delim_argv "foo $@ bar")" + cat <<'EOF' > h-f1 + +delim_argv() { + str= + while [ $# -gt 0 ]; do + if [ -z "${str}" ]; then + str=">$1<" + else + str="${str} >$1<" + fi + shift + done + echo "${str}" +} + +EOF + cat <<'EOF' > h-f2 + +delim_argv() { + str= + while [ $# -gt 0 ]; do + + str="${str}${str:+ }>$1<" + shift + + done + echo "${str}" +} + +EOF + + chmod +x h-f1 h-f2 + + for f in 1 2 + do + atf_check -s exit:0 -o inline:'\n' -e empty ${TEST_SH} -c \ + ". ./h-f${f}; "'set -- ; delim_argv "$@"' + atf_check -s exit:0 -o inline:'>foobar<\n' -e empty \ + ${TEST_SH} -c \ + ". ./h-f${f}; "'set -- ; delim_argv "foo$@bar"' + atf_check -s exit:0 -o inline:'>foo bar<\n' -e empty \ + ${TEST_SH} -c \ + ". ./h-f${f}; "'set -- ; delim_argv "foo $@ bar"' + + atf_check -s exit:0 -o inline:'>a< >b< >c<\n' -e empty \ + ${TEST_SH} -c \ + ". ./h-f${f}; "'set -- a b c; delim_argv "$@"' + atf_check -s exit:0 -o inline:'>fooa< >b< >cbar<\n' -e empty \ + ${TEST_SH} -c \ + ". ./h-f${f}; "'set -- a b c; delim_argv "foo$@bar"' + atf_check -s exit:0 -o inline:'>foo a< >b< >c bar<\n' -e empty \ + ${TEST_SH} -c \ + ". ./h-f${f}; "'set -- a b c; delim_argv "foo $@ bar"' + done } atf_test_case strip @@ -91,8 +135,25 @@ strip_head() { strip_body() { line='#define bindir "/usr/bin" /* comment */' stripped='#define bindir "/usr/bin" ' - atf_expect_fail "PR bin/43469" - atf_check_equal '$stripped' '${line%%/\**}' + + # atf_expect_fail "PR bin/43469" -- now fixed + for exp in \ + '${line%%/\**}' \ + '${line%%"/*"*}' \ + '${line%%'"'"'/*'"'"'*}' \ + '"${line%%/\**}"' \ + '"${line%%"/*"*}"' \ + '"${line%%'"'"'/*'"'"'*}"' \ + '${line%/\**}' \ + '${line%"/*"*}' \ + '${line%'"'"'/*'"'"'*}' \ + '"${line%/\**}"' \ + '"${line%"/*"*}"' \ + '"${line%'"'"'/*'"'"'*}"' + do + atf_check -o inline:":$stripped:\n" -e empty ${TEST_SH} -c \ + "line='${line}'; echo :${exp}:" + done } atf_test_case varpattern_backslashes @@ -103,7 +164,8 @@ varpattern_backslashes_head() { varpattern_backslashes_body() { line='/foo/bar/*/baz' stripped='/foo/bar/' - atf_check_equal $stripped ${line%%\**} + atf_check -o inline:'/foo/bar/\n' -e empty ${TEST_SH} -c \ + 'line="/foo/bar/*/baz"; echo ${line%%\**}' } atf_test_case arithmetic @@ -114,9 +176,13 @@ arithmetic_head() { "this is true." } arithmetic_body() { - atf_check_equal '3' '$((1 + 2))' - atf_check_equal '2147483647' '$((0x7fffffff))' - atf_check_equal '9223372036854775807' '$(((1 << 63) - 1))' + + atf_check -o inline:'3' -e empty ${TEST_SH} -c \ + 'printf %s $((1 + 2))' + atf_check -o inline:'2147483647' -e empty ${TEST_SH} -c \ + 'printf %s $((0x7fffffff))' + atf_check -o inline:'9223372036854775807' -e empty ${TEST_SH} -c \ + 'printf %s $(((1 << 63) - 1))' } atf_test_case iteration_on_null_parameter @@ -126,10 +192,178 @@ iteration_on_null_parameter_head() { "PR bin/48202." } iteration_on_null_parameter_body() { - s1=`/bin/sh -uc 'N=; set -- ${N}; for X; do echo "[$X]"; done' 2>&1` - s2=`/bin/sh -uc 'N=; set -- ${N:-}; for X; do echo "[$X]"; done' 2>&1` - atf_check_equal '' '$s1' - atf_check_equal '[]' '$s2' + atf_check -o empty -e empty ${TEST_SH} -c \ + 'N=; set -- ${N}; for X; do echo "[$X]"; done' +} + +atf_test_case iteration_on_quoted_null_parameter +iteration_on_quoted_null_parameter_head() { + atf_set "descr" \ + 'Check iteration of "$@" in for loop when set to null;' +} +iteration_on_quoted_null_parameter_body() { + atf_check -o inline:'[]\n' -e empty ${TEST_SH} -c \ + 'N=; set -- "${N}"; for X; do echo "[$X]"; done' +} + +atf_test_case iteration_on_null_or_null_parameter +iteration_on_null_or_null_parameter_head() { + atf_set "descr" \ + 'Check expansion of null parameter as default for another null' +} +iteration_on_null_or_null_parameter_body() { + atf_check -o empty -e empty ${TEST_SH} -c \ + 'N=; E=; set -- ${N:-${E}}; for X; do echo "[$X]"; done' +} + +atf_test_case iteration_on_null_or_missing_parameter +iteration_on_null_or_missing_parameter_head() { + atf_set "descr" \ + 'Check expansion of missing parameter as default for another null' +} +iteration_on_null_or_missing_parameter_body() { + # atf_expect_fail 'PR bin/50834' + atf_check -o empty -e empty ${TEST_SH} -c \ + 'N=; set -- ${N:-}; for X; do echo "[$X]"; done' +} + +nl=' +' +reset() +{ + TEST_NUM=0 + TEST_FAILURES='' + TEST_FAIL_COUNT=0 + TEST_ID="$1" +} + +check() +{ + fail=false + TEMP_FILE=$( mktemp OUT.XXXXXX ) + TEST_NUM=$(( $TEST_NUM + 1 )) + MSG= + + # our local shell (ATF_SHELL) better do quoting correctly... + # some of the tests expect us to expand $nl internally... + CMD="$1" + + result="$( ${TEST_SH} -c "${CMD}" 2>"${TEMP_FILE}" )" + STATUS=$? + + if [ "${STATUS}" -ne "$3" ]; then + MSG="${MSG}${MSG:+${nl}}[$TEST_NUM]" + MSG="${MSG} expected exit code $3, got ${STATUS}" + + # don't actually fail just because of wrong exit code + # unless we either expected, or received "good" + case "$3/${STATUS}" in + (*/0|0/*) fail=true;; + esac + fi + + if [ "$3" -eq 0 ]; then + if [ -s "${TEMP_FILE}" ]; then + MSG="${MSG}${MSG:+${nl}}[$TEST_NUM]" + MSG="${MSG} Messages produced on stderr unexpected..." + MSG="${MSG}${nl}$( cat "${TEMP_FILE}" )" + fail=true + fi + else + if ! [ -s "${TEMP_FILE}" ]; then + MSG="${MSG}${MSG:+${nl}}[$TEST_NUM]" + MSG="${MSG} Expected messages on stderr," + MSG="${MSG} nothing produced" + fail=true + fi + fi + rm -f "${TEMP_FILE}" + + # Remove newlines (use local shell for this) + oifs="$IFS" + IFS="$nl" + result="$(echo $result)" + IFS="$oifs" + if [ "$2" != "$result" ] + then + MSG="${MSG}${MSG:+${nl}}[$TEST_NUM]" + MSG="${MSG} Expected output '$2', received '$result'" + fail=true + fi + + if $fail + then + MSG="${MSG}${MSG:+${nl}}[$TEST_NUM]" + MSG="${MSG} Full command: <<${CMD}>>" + fi + + $fail && test -n "$TEST_ID" && { + TEST_FAILURES="${TEST_FAILURES}${TEST_FAILURES:+${nl}}" + TEST_FAILURES="${TEST_FAILURES}${TEST_ID}[$TEST_NUM]:" + TEST_FAILURES="${TEST_FAILURES} Test of '$1' failed."; + TEST_FAILURES="${TEST_FAILURES}${nl}${MSG}" + TEST_FAIL_COUNT=$(( $TEST_FAIL_COUNT + 1 )) + return 0 + } + $fail && atf_fail "Test[$TEST_NUM] of '$1' failed${nl}${MSG}" + return 0 +} + +results() +{ + test -z "${TEST_ID}" && return 0 + test -z "${TEST_FAILURES}" && return 0 + + echo >&2 "==========================================" + echo >&2 "While testing '${TEST_ID}'" + echo >&2 " - - - - - - - - - - - - - - - - -" + echo >&2 "${TEST_FAILURES}" + atf_fail \ + "Test ${TEST_ID}: $TEST_FAIL_COUNT subtests (of $TEST_NUM) failed - see stderr" +} + +atf_test_case shell_params +shell_params_head() { + atf_set "descr" "Test correct operation of the numeric parameters" +} +shell_params_body() { + atf_require_prog mktemp + + reset shell_params + + check 'set -- a b c; echo "$#: $1 $2 $3"' '3: a b c' 0 + check 'set -- a b c d e f g h i j k l m; echo "$#: ${1}0 ${10} $10"' \ + '13: a0 j a0' 0 + check 'x="$0"; set -- a b; y="$0"; + [ "x${x}y" = "x${y}y" ] && echo OK || echo x="$x" y="$y"' \ + 'OK' 0 + check "${TEST_SH} -c 'echo 0=\$0 1=\$1 2=\$2' a b c" '0=a 1=b 2=c' 0 + + echo 'echo 0="$0" 1="$1" 2="$2"' > helper.sh + check "${TEST_SH} helper.sh a b c" '0=helper.sh 1=a 2=b' 0 + + check 'set -- a bb ccc dddd eeeee ffffff ggggggg hhhhhhhh \ + iiiiiiiii jjjjjjjjjj kkkkkkkkkkk + echo "${#}: ${#1} ${#2} ${#3} ${#4} ... ${#9} ${#10} ${#11}"' \ + '11: 1 2 3 4 ... 9 10 11' 0 + + check 'set -- a b c; echo "$#: ${1-A} ${2-B} ${3-C} ${4-D} ${5-E}"' \ + '3: a b c D E' 0 + check 'set -- a "" c "" e + echo "$#: ${1:-A} ${2:-B} ${3:-C} ${4:-D} ${5:-E}"' \ + '5: a B c D e' 0 + check 'set -- a "" c "" e + echo "$#: ${1:+A} ${2:+B} ${3:+C} ${4:+D} ${5:+E}"' \ + '5: A C E' 0 + check 'set -- "abab*cbb" + echo "${1} ${1#a} ${1%b} ${1##ab} ${1%%b} ${1#*\*} ${1%\**}"' \ + 'abab*cbb bab*cbb abab*cb ab*cbb abab*cb cbb abab' 0 + check 'set -- "abab?cbb" + echo "${1}:${1#*a}+${1%b*}-${1##*a}_${1%%b*}%${1#[ab]}=${1%?*}/${1%\?*}"' \ + 'abab?cbb:bab?cbb+abab?cb-b?cbb_a%bab?cbb=abab?cb/abab' 0 + check 'set -- a "" c "" e; echo "${2:=b}"' '' 1 + + results } atf_init_test_cases() { @@ -139,4 +373,8 @@ atf_init_test_cases() { atf_add_test_case varpattern_backslashes atf_add_test_case arithmetic atf_add_test_case iteration_on_null_parameter + atf_add_test_case iteration_on_quoted_null_parameter + atf_add_test_case iteration_on_null_or_null_parameter + atf_add_test_case iteration_on_null_or_missing_parameter + atf_add_test_case shell_params } diff --git a/contrib/netbsd-tests/bin/sh/t_fsplit.sh b/contrib/netbsd-tests/bin/sh/t_fsplit.sh index 2c3dbae..a37804b 100755 --- a/contrib/netbsd-tests/bin/sh/t_fsplit.sh +++ b/contrib/netbsd-tests/bin/sh/t_fsplit.sh @@ -1,6 +1,6 @@ -# $NetBSD: t_fsplit.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# $NetBSD: t_fsplit.sh,v 1.4 2016/03/27 14:50:01 christos Exp $ # -# Copyright (c) 2007 The NetBSD Foundation, Inc. +# Copyright (c) 2007-2016 The NetBSD Foundation, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -33,22 +33,51 @@ # the "${x-" and "}" were absent from the input line. # # So: sh -c 'set ${x-a b c}; echo $#' should give 3. +# and: sh -c 'set -- ${x-}' echo $#' shold give 0 # +# the implementation of "sh" to test +: ${TEST_SH:="/bin/sh"} + nl=' ' check() { - result="$(eval $1)" + TEST=$((${TEST} + 1)) + + case "$#" in + (2) ;; + (*) atf_fail "Internal test error, $# args to check test ${TEST}";; + esac + + result=$( ${TEST_SH} -c "unset x; $1" ) + STATUS="$?" + # Remove newlines oifs="$IFS" IFS="$nl" result="$(echo $result)" IFS="$oifs" + + # trim the test text in case we use it in a message below + case "$1" in + ????????????????*) + set -- "$(expr "$1" : '\(............\).*')..." "$2" ;; + esac + if [ "$2" != "$result" ] then - atf_fail "expected [$2], found [$result]" + if [ "${STATUS}" = "0" ] + then + atf_fail "Test ${TEST} '$1': expected [$2], found [$result]" + else + atf_fail \ + "TEST ${TEST} '$1' failed ($STATUS): expected [$2], found [$result]" + fi + elif [ "${STATUS}" != 0 ] + then + atf_fail "TEST ${TEST} '$1' failed ($STATUS)" fi } @@ -59,6 +88,7 @@ for_head() { for_body() { unset x + TEST=0 # Since I managed to break this, leave the test in check 'for f in $x; do echo x${f}y; done' '' } @@ -68,17 +98,121 @@ default_val_head() { atf_set "descr" "Checks field splitting in variable default values" } default_val_body() { - unset x - + TEST=0 # Check that IFS is applied to text from ${x-...} unless it is inside # any set of "..." - check 'set ${x-a b c}; echo $#' 3 - check 'for i in ${x-a b c}; do echo "z${i}z"; done' 'zaz zbz zcz' - check 'for i in ${x-"a b" c}; do echo "z${i}z"; done' 'za bz zcz' - check 'for i in ${x-"a ${x-b c}" d}; do echo "z${i}z"; done' 'za b cz zdz' - check 'for i in ${x-"a ${x-"b c"}" d}; do echo "z${i}z"; done' 'za b cz zdz' - check 'for i in ${x-a ${x-"b c"} d}; do echo "z${i}z"; done' 'zaz zb cz zdz' - check 'for i in ${x-a ${x-b c} d}; do echo "z${i}z"; done' 'zaz zbz zcz zdz' + check 'set -- ${x-a b c}; echo $#' 3 + + check 'set -- ${x-"a b" c}; echo $#' 2 + check 'set -- ${x-a "b c"}; echo $#' 2 + check 'set -- ${x-"a b c"}; echo $#' 1 + + check "set -- \${x-'a b' c}; echo \$#" 2 + check "set -- \${x-a 'b c'}; echo \$#" 2 + check "set -- \${x-'a b c'}; echo \$#" 1 + + check 'set -- ${x-a\ b c}; echo $#' 2 + check 'set -- ${x-a b\ c}; echo $#' 2 + check 'set -- ${x-a\ b\ c}; echo $#' 1 + + check 'set -- ${x}; echo $#' 0 + check 'set -- ${x-}; echo $#' 0 + check 'set -- ${x-""}; echo $#' 1 + check 'set -- ""${x}; echo $#' 1 + check 'set -- ""${x-}; echo $#' 1 + check 'set -- ""${x-""}; echo $#' 1 + check 'set -- ${x}""; echo $#' 1 + check 'set -- ${x-}""; echo $#' 1 + check 'set -- ${x-""}""; echo $#' 1 + check 'set -- ""${x}""; echo $#' 1 + check 'set -- ""${x-}""; echo $#' 1 + check 'set -- ""${x-""}""; echo $#' 1 + + check 'for i in ${x-a b c}; do echo "z${i}z"; done' \ + 'zaz zbz zcz' + check 'for i in ${x-"a b" c}; do echo "z${i}z"; done' \ + 'za bz zcz' + check 'for i in ${x-"a ${x-b c}" d}; do echo "z${i}z"; done' \ + 'za b cz zdz' + check 'for i in ${x-a ${x-b c} d}; do echo "z${i}z"; done' \ + 'zaz zbz zcz zdz' + + # I am not sure these two are correct, the rules on quoting word + # in ${var-word} are peculiar, and hard to fathom... + # They are what the NetBSD shell does, and bash, not the freebsd shell + # (as of Mar 1, 2016) + + check 'for i in ${x-"a ${x-"b c"}" d}; do echo "z${i}z"; done' \ + 'za b cz zdz' + check 'for i in ${x-a ${x-"b c"} d}; do echo "z${i}z"; done' \ + 'zaz zb cz zdz' +} + +atf_test_case replacement_val +replacement_val_head() { + atf_set "descr" "Checks field splitting in variable replacement values" +} +replacement_val_body() { + TEST=0 + + # Check that IFS is applied to text from ${x+...} unless it is inside + # any set of "...", or whole expansion is quoted, or both... + + check 'x=BOGUS; set -- ${x+a b c}; echo $#' 3 + + check 'x=BOGUS; set -- ${x+"a b" c}; echo $#' 2 + check 'x=BOGUS; set -- ${x+a "b c"}; echo $#' 2 + check 'x=BOGUS; set -- ${x+"a b c"}; echo $#' 1 + + check "x=BOGUS; set -- \${x+'a b' c}; echo \$#" 2 + check "x=BOGUS; set -- \${x+a 'b c'}; echo \$#" 2 + check "x=BOGUS; set -- \${x+'a b c'}; echo \$#" 1 + + check 'x=BOGUS; set -- ${x+a\ b c}; echo $#' 2 + check 'x=BOGUS; set -- ${x+a b\ c}; echo $#' 2 + check 'x=BOGUS; set -- ${x+a\ b\ c}; echo $#' 1 + + check 'x=BOGUS; set -- ${x+}; echo $#' 0 + check 'x=BOGUS; set -- ${x+""}; echo $#' 1 + check 'x=BOGUS; set -- ""${x+}; echo $#' 1 + check 'x=BOGUS; set -- ""${x+""}; echo $#' 1 + check 'x=BOGUS; set -- ${x+}""; echo $#' 1 + check 'x=BOGUS; set -- ${x+""}""; echo $#' 1 + check 'x=BOGUS; set -- ""${x+}""; echo $#' 1 + check 'x=BOGUS; set -- ""${x+""}""; echo $#' 1 + + # verify that the value of $x does not affecty the value of ${x+...} + check 'x=BOGUS; set -- ${x+}; echo X$1' X + check 'x=BOGUS; set -- ${x+""}; echo X$1' X + check 'x=BOGUS; set -- ""${x+}; echo X$1' X + check 'x=BOGUS; set -- ""${x+""}; echo X$1' X + check 'x=BOGUS; set -- ${x+}""; echo X$1' X + check 'x=BOGUS; set -- ${x+""}""; echo X$1' X + check 'x=BOGUS; set -- ""${x+}""; echo X$1' X + check 'x=BOGUS; set -- ""${x+""}""; echo X$1' X + + check 'x=BOGUS; set -- ${x+}; echo X${1-:}X' X:X + check 'x=BOGUS; set -- ${x+""}; echo X${1-:}X' XX + check 'x=BOGUS; set -- ""${x+}; echo X${1-:}X' XX + check 'x=BOGUS; set -- ""${x+""}; echo X${1-:}X' XX + check 'x=BOGUS; set -- ${x+}""; echo X${1-:}X' XX + check 'x=BOGUS; set -- ${x+""}""; echo X${1-:}X' XX + check 'x=BOGUS; set -- ""${x+}""; echo X${1-:}X' XX + check 'x=BOGUS; set -- ""${x+""}""; echo X${1-:}X' XX + + # and validate that the replacement can be used as expected + check 'x=BOGUS; for i in ${x+a b c}; do echo "z${i}z"; done'\ + 'zaz zbz zcz' + check 'x=BOGUS; for i in ${x+"a b" c}; do echo "z${i}z"; done'\ + 'za bz zcz' + check 'x=BOGUS; for i in ${x+"a ${x+b c}" d}; do echo "z${i}z"; done'\ + 'za b cz zdz' + check 'x=BOGUS; for i in ${x+"a ${x+"b c"}" d}; do echo "z${i}z"; done'\ + 'za b cz zdz' + check 'x=BOGUS; for i in ${x+a ${x+"b c"} d}; do echo "z${i}z"; done'\ + 'zaz zb cz zdz' + check 'x=BOGUS; for i in ${x+a ${x+b c} d}; do echo "z${i}z"; done'\ + 'zaz zbz zcz zdz' } atf_test_case ifs_alpha @@ -89,13 +223,19 @@ ifs_alpha_head() { ifs_alpha_body() { unset x + TEST=0 # repeat with an alphabetic in IFS check 'IFS=q; set ${x-aqbqc}; echo $#' 3 - check 'IFS=q; for i in ${x-aqbqc}; do echo "z${i}z"; done' 'zaz zbz zcz' - check 'IFS=q; for i in ${x-"aqb"qc}; do echo "z${i}z"; done' 'zaqbz zcz' - check 'IFS=q; for i in ${x-"aq${x-bqc}"qd}; do echo "z${i}z"; done' 'zaqbqcz zdz' - check 'IFS=q; for i in ${x-"aq${x-"bqc"}"qd}; do echo "z${i}z"; done' 'zaqbqcz zdz' - check 'IFS=q; for i in ${x-aq${x-"bqc"}qd}; do echo "z${i}z"; done' 'zaz zbqcz zdz' + check 'IFS=q; for i in ${x-aqbqc}; do echo "z${i}z"; done' \ + 'zaz zbz zcz' + check 'IFS=q; for i in ${x-"aqb"qc}; do echo "z${i}z"; done' \ + 'zaqbz zcz' + check 'IFS=q; for i in ${x-"aq${x-bqc}"qd}; do echo "z${i}z"; done' \ + 'zaqbqcz zdz' + check 'IFS=q; for i in ${x-"aq${x-"bqc"}"qd}; do echo "z${i}z"; done' \ + 'zaqbqcz zdz' + check 'IFS=q; for i in ${x-aq${x-"bqc"}qd}; do echo "z${i}z"; done' \ + 'zaz zbqcz zdz' } atf_test_case quote @@ -106,6 +246,7 @@ quote_head() { quote_body() { unset x + TEST=0 # Some quote propagation checks check 'set "${x-a b c}"; echo $#' 1 check 'set "${x-"a b" c}"; echo $1' 'a b c' @@ -120,19 +261,44 @@ dollar_at_head() { dollar_at_body() { unset x + TEST=0 # Check we get "$@" right - check 'set ""; for i; do echo "z${i}z"; done' 'zz' - check 'set ""; for i in "$@"; do echo "z${i}z"; done' 'zz' - check 'set "" ""; for i; do echo "z${i}z"; done' 'zz zz' - check 'set "" ""; for i in "$@"; do echo "z${i}z"; done' 'zz zz' - check 'set "" ""; for i in $@; do echo "z${i}z"; done' '' - check 'set "a b" c; for i; do echo "z${i}z"; done' 'za bz zcz' - check 'set "a b" c; for i in "$@"; do echo "z${i}z"; done' 'za bz zcz' - check 'set "a b" c; for i in $@; do echo "z${i}z"; done' 'zaz zbz zcz' - check 'set " a b " c; for i in "$@"; do echo "z${i}z"; done' 'z a b z zcz' - check 'set --; for i in x"$@"x; do echo "z${i}z"; done' 'zxxz' - check 'set a; for i in x"$@"x; do echo "z${i}z"; done' 'zxaxz' - check 'set a b; for i in x"$@"x; do echo "z${i}z"; done' 'zxaz zbxz' + + check 'set --; for i in x"$@"x; do echo "z${i}z"; done' 'zxxz' + check 'set a; for i in x"$@"x; do echo "z${i}z"; done' 'zxaxz' + check 'set a b; for i in x"$@"x; do echo "z${i}z"; done' 'zxaz zbxz' + + check 'set --; for i; do echo "z${i}z"; done' '' + check 'set --; for i in $@; do echo "z${i}z"; done' '' + check 'set --; for i in "$@"; do echo "z${i}z"; done' '' + # atf_expect_fail "PR bin/50834" + check 'set --; for i in ""$@; do echo "z${i}z"; done' 'zz' + # atf_expect_pass + check 'set --; for i in $@""; do echo "z${i}z"; done' 'zz' + check 'set --; for i in ""$@""; do echo "z${i}z"; done' 'zz' + check 'set --; for i in """$@"; do echo "z${i}z"; done' 'zz' + check 'set --; for i in "$@"""; do echo "z${i}z"; done' 'zz' + check 'set --; for i in """$@""";do echo "z${i}z"; done' 'zz' + + check 'set ""; for i; do echo "z${i}z"; done' 'zz' + check 'set ""; for i in "$@"; do echo "z${i}z"; done' 'zz' + check 'set "" ""; for i; do echo "z${i}z"; done' 'zz zz' + check 'set "" ""; for i in "$@"; do echo "z${i}z"; done' 'zz zz' + check 'set "" ""; for i in $@; do echo "z${i}z"; done' '' + + check 'set "a b" c; for i; do echo "z${i}z"; done' \ + 'za bz zcz' + check 'set "a b" c; for i in "$@"; do echo "z${i}z"; done' \ + 'za bz zcz' + check 'set "a b" c; for i in $@; do echo "z${i}z"; done' \ + 'zaz zbz zcz' + check 'set " a b " c; for i in "$@"; do echo "z${i}z"; done' \ + 'z a b z zcz' + + check 'set a b c; for i in "$@$@"; do echo "z${i}z"; done' \ + 'zaz zbz zcaz zbz zcz' + check 'set a b c; for i in "$@""$@";do echo "z${i}z"; done' \ + 'zaz zbz zcaz zbz zcz' } atf_test_case ifs @@ -143,6 +309,7 @@ ifs_head() { ifs_body() { unset x + TEST=0 # Some IFS tests check 't="-- "; IFS=" "; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '0' check 't=" x"; IFS=" x"; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '1' @@ -165,19 +332,26 @@ var_length_head() { "a variable's length" } var_length_body() { - unset x + TEST=0 - # Check that we apply IFS to ${#var} long=12345678123456781234567812345678 long=$long$long$long$long - check 'echo ${#long}; IFS=2; echo ${#long}; set 1 ${#long};echo $#' '128 1 8 3' - check 'IFS=2; set ${x-${#long}}; IFS=" "; echo $* $#' '1 8 2' - check 'IFS=2; set ${x-"${#long}"}; IFS=" "; echo $* $#' '128 1' + export long + + # first test that the test method works... + check 'set -u; : ${long}; echo ${#long}' '128' + + # Check that we apply IFS to ${#var} + check 'echo ${#long}; IFS=2; echo ${#long}; set 1 ${#long};echo $#' \ + '128 1 8 3' + check 'IFS=2; set ${x-${#long}}; IFS=" "; echo $* $#' '1 8 2' + check 'IFS=2; set ${x-"${#long}"}; IFS=" "; echo $* $#' '128 1' } atf_init_test_cases() { atf_add_test_case for atf_add_test_case default_val + atf_add_test_case replacement_val atf_add_test_case ifs_alpha atf_add_test_case quote atf_add_test_case dollar_at diff --git a/contrib/netbsd-tests/bin/sh/t_here.sh b/contrib/netbsd-tests/bin/sh/t_here.sh index 250c686..27307f5 100755 --- a/contrib/netbsd-tests/bin/sh/t_here.sh +++ b/contrib/netbsd-tests/bin/sh/t_here.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_here.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# $NetBSD: t_here.sh,v 1.6 2016/03/31 16:21:52 christos Exp $ # # Copyright (c) 2007 The NetBSD Foundation, Inc. # All rights reserved. @@ -24,50 +24,542 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # +# the implementation of "sh" to test +: ${TEST_SH:="/bin/sh"} nl=' ' +reset() +{ + TEST_NUM=0 + TEST_FAILURES='' + TEST_FAIL_COUNT=0 + TEST_ID="$1" +} + check() { - SVIFS="$IFS" - result="$(eval $1)" - # Remove newlines + fail=false + TEMP_FILE=$( mktemp OUT.XXXXXX ) + TEST_NUM=$(( $TEST_NUM + 1 )) + + # our local shell (ATF_SHELL) better do quoting correctly... + # some of the tests expect us to expand $nl internally... + CMD="nl='${nl}'; $1" + + result="$( ${TEST_SH} -c "${CMD}" 2>"${TEMP_FILE}" )" + STATUS=$? + + if [ "${STATUS}" -ne "$3" ]; then + echo >&2 "[$TEST_NUM] expected exit code $3, got ${STATUS}" + + # don't actually fail just because of wrong exit code + # unless we either expected, or received "good" + case "$3/${STATUS}" in + (*/0|0/*) fail=true;; + esac + fi + + if [ "$3" -eq 0 ]; then + if [ -s "${TEMP_FILE}" ]; then + echo >&2 \ + "[$TEST_NUM] Messages produced on stderr unexpected..." + cat "${TEMP_FILE}" >&2 + fail=true + fi + else + if ! [ -s "${TEMP_FILE}" ]; then + echo >&2 \ + "[$TEST_NUM] Expected messages on stderr, nothing produced" + fail=true + fi + fi + rm -f "${TEMP_FILE}" + + # Remove newlines (use local shell for this) oifs="$IFS" IFS="$nl" result="$(echo $result)" IFS="$oifs" if [ "$2" != "$result" ] then - atf_fail "expected [$2], found [$result]" + echo >&2 "[$TEST_NUM] Expected output '$2', received '$result'" + fail=true fi - IFS="$SVIFS" + + if $fail + then + echo >&2 "[$TEST_NUM] Full command: <<${CMD}>>" + fi + + $fail && test -n "$TEST_ID" && { + TEST_FAILURES="${TEST_FAILURES}${TEST_FAILURES:+ +}${TEST_ID}[$TEST_NUM]: test of '$1' failed"; + TEST_FAIL_COUNT=$(( $TEST_FAIL_COUNT + 1 )) + return 0 + } + $fail && atf_fail "Test[$TEST_NUM] of '$1' failed" + return 0 } -atf_test_case all -all_head() { +results() +{ + test -z "${TEST_ID}" && return 0 + test -z "${TEST_FAILURES}" && return 0 + + echo >&2 "==========================================" + echo >&2 "While testing '${TEST_ID}'" + echo >&2 " - - - - - - - - - - - - - - - - -" + echo >&2 "${TEST_FAILURES}" + atf_fail \ + "Test ${TEST_ID}: $TEST_FAIL_COUNT subtests (of $TEST_NUM) failed - see stderr" +} + +atf_test_case do_simple +do_simple_head() { atf_set "descr" "Basic tests for here documents" } -all_body() { +do_simple_body() { y=x - IFS= - check 'x=`cat < + E0F + ' '<'\''"'\'' \\$X\$X "'\''" \\>' 0 + + check 'X=!; cat <<- E0F + <'\''"'\'' \\$X\$X "'\''" \\> + E0F + ' '<'\''"'\'' \!$X "'\''" \>' 0 + + check 'cat <<- END + $( echo "'\''" ) $( echo '\''"'\'' ) $( echo \\ ) + END + ' "' \" \\" 0 + + check 'X=12345; Y="string1 line1?-line2"; Z=; unset W; cat <<-EOF + ${#X}${Z:-${Y}}${W+junk}${Y%%l*}${Y#*\?} + "$Z"'\''$W'\'' ${Y%" "*} $(( X + 54321 )) + EOF + ' '5string1 line1?-line2string1 -line2 ""'\'\'' string1 66666' 0 + + results +} + +atf_test_case side_effects +side_effects_head() { + atf_set "descr" "Tests how side effects in here documents are handled" +} +side_effects_body() { + + atf_check -s exit:0 -o inline:'2\n1\n' -e empty ${TEST_SH} -c ' + unset X + cat <<-EOF + ${X=2} + EOF + echo "${X-1}" + ' +} + +atf_test_case vicious +vicious_head() { + atf_set "descr" "Tests for obscure and obnoxious uses of here docs" +} +vicious_body() { + reset + + cat <<- \END_SCRIPT > script + cat < script + prefix() { sed -e "s/^/$1:/"; } + DASH_CODE() { :; } - check 'x=`cat <&2 + exit 1 + } + s() { + set -"$1" + t="$-" + x=$(echo "$t" | tr -d "$1") + test "$t" = "$x" && x set "$1" + return 0 + } + c() { + set +"$1" + t="$-" + x=$(echo "$t" | tr -d "$1") + test "$t" != "$x" && x clear "$1" + return 0 + } + '"${CLEAR}"' + + # if we do not do this, -x tracing splatters stderr + # for some shells, -v does as well (is that correct?) + case "${opt}" in + (*[xv]*) exec 2>/dev/null;; + esac + + o="$-" + x=$(echo "$o" | tr -d "$opt") + + if [ "$o" = "$x" ]; then # option was off + s "${opt}" + c "${opt}" + else + c "${opt}" + s "${opt}" + fi + ' + done +} + +test_optional_on_off() +{ + RET=0 + OPTS= + for opt + do + test "${opt}" = n && continue + ${TEST_SH} -c "set -${opt}" 2>/dev/null && + OPTS="${OPTS} ${opt}" || RET=1 + done + + test -n "${OPTS}" && test_option_on_off ${OPTS} + + return "${RET}" +} + +atf_test_case set_a +set_a_head() { + atf_set "descr" "Tests that 'set -a' turns on all var export " \ + "and that it behaves as defined by the standard" +} +set_a_body() { + atf_require_prog env + atf_require_prog grep + + test_option_on_off a + + # without -a, new variables should not be exported (so grep "fails") + atf_check -s exit:1 -o empty -e empty ${TEST_SH} -ce \ + 'unset VAR; set +a; VAR=value; env | grep "^VAR="' + + # with -a, they should be + atf_check -s exit:0 -o match:VAR=value -e empty ${TEST_SH} -ce \ + 'unset VAR; set -a; VAR=value; env | grep "^VAR="' +} + +atf_test_case set_C +set_C_head() { + atf_set "descr" "Tests that 'set -C' turns on no clobber mode " \ + "and that it behaves as defined by the standard" +} +set_C_body() { + atf_require_prog ls + + test_option_on_off C + + # Check that the environment to use for the tests is sane ... + # we assume current dir is a new tempory directory & is empty + + test -z "$(ls)" || atf_skip "Test execution directory not clean" + test -c "/dev/null" || atf_skip "Problem with /dev/null" + + echo Dummy_Content > Junk_File + echo Precious_Content > Important_File + + # Check that we can redirect onto file when -C is not set + atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \ + ' + D=$(ls -l Junk_File) || exit 1 + set +C + echo "Overwrite it now" > Junk_File + A=$(ls -l Junk_File) || exit 1 + test "${A}" != "${D}" + ' + + # Check that we cannot redirect onto file when -C is set + atf_check -s exit:0 -o empty -e not-empty ${TEST_SH} -c \ + ' + D=$(ls -l Important_File) || exit 1 + set -C + echo "Fail to Overwrite it now" > Important_File + A=$(ls -l Important_File) || exit 1 + test "${A}" = "${D}" + ' + + # Check that we can append to file, even when -C is set + atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \ + ' + D=$(ls -l Junk_File) || exit 1 + set -C + echo "Append to it now" >> Junk_File + A=$(ls -l Junk_File) || exit 1 + test "${A}" != "${D}" + ' + + # Check that we abort on attempt to redirect onto file when -Ce is set + atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \ + ' + set -Ce + echo "Fail to Overwrite it now" > Important_File + echo "Should not reach this point" + ' + + # Last check that we can override -C for when we really need to + atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \ + ' + D=$(ls -l Junk_File) || exit 1 + set -C + echo "Change the poor bugger again" >| Junk_File + A=$(ls -l Junk_File) || exit 1 + test "${A}" != "${D}" + ' +} + +atf_test_case set_e +set_e_head() { + atf_set "descr" "Tests that 'set -e' turns on error detection " \ + "and that a simple case behaves as defined by the standard" +} +set_e_body() { + test_option_on_off e + + # Check that -e does nothing if no commands fail + atf_check -s exit:0 -o match:I_am_OK -e empty \ + ${TEST_SH} -c \ + 'false; printf "%s" I_am; set -e; true; printf "%s\n" _OK' + + # and that it (silently, but with exit status) aborts if cmd fails + atf_check -s not-exit:0 -o match:I_am -o not-match:Broken -e empty \ + ${TEST_SH} -c \ + 'false; printf "%s" I_am; set -e; false; printf "%s\n" _Broken' + + # same, except -e this time is on from the beginning + atf_check -s not-exit:0 -o match:I_am -o not-match:Broken -e empty \ + ${TEST_SH} -ec 'printf "%s" I_am; false; printf "%s\n" _Broken' + + # More checking of -e in other places, there is lots to deal with. +} + +atf_test_case set_f +set_f_head() { + atf_set "descr" "Tests that 'set -f' turns off pathname expansion " \ + "and that it behaves as defined by the standard" +} +set_f_body() { + atf_require_prog ls + + test_option_on_off f + + # Check that the environment to use for the tests is sane ... + # we assume current dir is a new tempory directory & is empty + + test -z "$(ls)" || atf_skip "Test execution directory not clean" + + # we will assume that atf will clean up this junk directory + # when we are done. But for testing pathname expansion + # we need files + + for f in a b c d e f aa ab ac ad ae aaa aab aac aad aba abc bbb ccc + do + echo "$f" > "$f" + done + + atf_check -s exit:0 -o empty -e empty ${TEST_SH} -ec \ + 'X=$(echo b*); Y=$(echo b*); test "${X}" != "a*"; + test "${X}" = "${Y}"' + + # now test expansion is different when -f is set + atf_check -s exit:0 -o empty -e empty ${TEST_SH} -ec \ + 'X=$(echo b*); Y=$(set -f; echo b*); test "${X}" != "${Y}"' +} + +atf_test_case set_n +set_n_head() { + atf_set "descr" "Tests that 'set -n' supresses command execution " \ + "and that it behaves as defined by the standard" +} +set_n_body() { + # pointless to test this, if it turns on, it stays on... + # test_option_on_off n + # so just allow the tests below to verify it can be turned on + + # nothing should be executed, hence no output... + atf_check -s exit:0 -o empty -e empty \ + ${TEST_SH} -enc 'echo ABANDON HOPE; echo ALL YE; echo ...' + + # this is true even when the "commands" do not exist + atf_check -s exit:0 -o empty -e empty \ + ${TEST_SH} -enc 'ERR; FAIL; ABANDON HOPE' + + # but if there is a syntax error, it should be detected (w or w/o -e) + atf_check -s not-exit:0 -o empty -e not-empty \ + ${TEST_SH} -enc 'echo JUMP; for frogs swim; echo in puddles' + atf_check -s not-exit:0 -o empty -e not-empty \ + ${TEST_SH} -nc 'echo ABANDON HOPE; echo "ALL YE; echo ...' + atf_check -s not-exit:0 -o empty -e not-empty \ + ${TEST_SH} -enc 'echo ABANDON HOPE;; echo ALL YE; echo ...' + atf_check -s not-exit:0 -o empty -e not-empty \ + ${TEST_SH} -nc 'do YOU ABANDON HOPE; for all eternity?' + + # now test enabling -n in the middle of a script + # note that once turned on, it cannot be turned off again. + # + # omit more complex cases, as those can send some shells + # into infinite loops, and believe it or not, that might be OK! + + atf_check -s exit:0 -o match:first -o not-match:second -e empty \ + ${TEST_SH} -c 'echo first; set -n; echo second' + atf_check -s exit:0 -o match:first -o not-match:third -e empty \ + ${TEST_SH} -c 'echo first; set -n; echo second; set +n; echo third' + atf_check -s exit:0 -o inline:'a\nb\n' -e empty \ + ${TEST_SH} -c 'for x in a b c d + do + case "$x" in + a);; b);; c) set -n;; d);; + esac + printf "%s\n" "$x" + done' + + # This last one is a bit more complex to explain, so I will not try + + # First, we need to know what signal number is used for SIGUSR1 on + # the local (testing) system (signal number is $(( $XIT - 128 )) ) + + # this will take slightly over 1 second elapsed time (the sleep 1) + # The "10" for the first sleep just needs to be something big enough + # that the rest of the commands have time to complete, even on + # very slow testing systems. 10 should be enough. Otherwise irrelevant + + # The shell will usually blather to stderr about the sleep 10 being + # killed, but it affects nothing, so just allow it to cry. + + (sleep 10 & sleep 1; kill -USR1 $!; wait $!) + XIT="$?" + + # The exit value should be an integer > 128 and < 256 (often 158) + # If it is not just skip the test + + # If we do run the test, it should take (slightly over) either 1 or 2 + # seconds to complete, depending upon the shell being tested. + + case "${XIT}" in + ( 129 | 1[3-9][0-9] | 2[0-4][0-9] | 25[0-5] ) + + # The script below should exit with the same code - no output + + # Or that is the result that seems best explanable. + # "set -n" in uses like this is not exactly well defined... + + # This script comes from a member of the austin group + # (they author changes to the posix shell spec - and more.) + # The author is also an (occasional?) NetBSD user. + atf_check -s exit:${XIT} -o empty -e empty ${TEST_SH} -c ' + trap "set -n" USR1 + { sleep 1; kill -USR1 $$; sleep 1; } & + false + wait && echo t || echo f + wait + echo foo + ' + ;; + esac +} + +atf_test_case set_u +set_u_head() { + atf_set "descr" "Tests that 'set -u' turns on unset var detection " \ + "and that it behaves as defined by the standard" +} +set_u_body() { + test_option_on_off u + + # first make sure it is OK to unset an unset variable + atf_check -s exit:0 -o match:OK -e empty ${TEST_SH} -ce \ + 'unset _UNSET_VARIABLE_; echo OK' + # even if -u is set + atf_check -s exit:0 -o match:OK -e empty ${TEST_SH} -cue \ + 'unset _UNSET_VARIABLE_; echo OK' + + # and that without -u accessing an unset variable is harmless + atf_check -s exit:0 -o match:OK -e empty ${TEST_SH} -ce \ + 'unset X; echo ${X}; echo OK' + # and that the unset variable test expansion works properly + atf_check -s exit:0 -o match:OKOK -e empty ${TEST_SH} -ce \ + 'unset X; printf "%s" ${X-OK}; echo OK' + + # Next test that with -u set, the shell aborts on access to unset var + # do not use -e, want to make sure it is -u that causes abort + atf_check -s not-exit:0 -o not-match:ERR -e not-empty ${TEST_SH} -c \ + 'unset X; set -u; echo ${X}; echo ERR' + # quoting should make no difference... + atf_check -s not-exit:0 -o not-match:ERR -e not-empty ${TEST_SH} -c \ + 'unset X; set -u; echo "${X}"; echo ERR' + + # Now a bunch of accesses to unset vars, with -u, in ways that are OK + atf_check -s exit:0 -o match:OK -e empty ${TEST_SH} -ce \ + 'unset X; set -u; echo ${X-GOOD}; echo OK' + atf_check -s exit:0 -o match:OK -e empty ${TEST_SH} -ce \ + 'unset X; set -u; echo ${X-OK}' + atf_check -s exit:0 -o not-match:ERR -o match:OK -e empty \ + ${TEST_SH} -ce 'unset X; set -u; echo ${X+ERR}; echo OK' + + # and some more ways that are not OK + atf_check -s not-exit:0 -o not-match:ERR -e not-empty ${TEST_SH} -c \ + 'unset X; set -u; echo ${X#foo}; echo ERR' + atf_check -s not-exit:0 -o not-match:ERR -e not-empty ${TEST_SH} -c \ + 'unset X; set -u; echo ${X%%bar}; echo ERR' + + # lastly, just while we are checking unset vars, test aborts w/o -u + atf_check -s not-exit:0 -o not-match:ERR -e not-empty ${TEST_SH} -c \ + 'unset X; echo ${X?}; echo ERR' + atf_check -s not-exit:0 -o not-match:ERR -e match:X_NOT_SET \ + ${TEST_SH} -c 'unset X; echo ${X?X_NOT_SET}; echo ERR' +} + +atf_test_case set_v +set_v_head() { + atf_set "descr" "Tests that 'set -v' turns on input read echoing " \ + "and that it behaves as defined by the standard" +} +set_v_body() { + test_option_on_off v + + # check that -v does nothing if no later input line is read + atf_check -s exit:0 \ + -o match:OKOK -o not-match:echo -o not-match:printf \ + -e empty \ + ${TEST_SH} -ec 'printf "%s" OK; set -v; echo OK; exit 0' + + # but that it does when there are multiple lines + cat <<- 'EOF' | + set -v + printf %s OK + echo OK + exit 0 + EOF + atf_check -s exit:0 \ + -o match:OKOK -o not-match:echo -o not-match:printf \ + -e match:printf -e match:OK -e match:echo \ + -e not-match:set ${TEST_SH} + + # and that it can be disabled again + cat <<- 'EOF' | + set -v + printf %s OK + set +v + echo OK + exit 0 + EOF + atf_check -s exit:0 \ + -o match:OKOK -o not-match:echo -o not-match:printf \ + -e match:printf -e match:OK -e not-match:echo \ + ${TEST_SH} + + # and lastly, that shell keywords do get output when "read" + cat <<- 'EOF' | + set -v + for i in 111 222 333 + do + printf %s $i + done + exit 0 + EOF + atf_check -s exit:0 \ + -o match:111222333 -o not-match:printf \ + -o not-match:for -o not-match:do -o not-match:done \ + -e match:printf -e match:111 -e not-match:111222 \ + -e match:for -e match:do -e match:done \ + ${TEST_SH} +} + +atf_test_case set_x +set_x_head() { + atf_set "descr" "Tests that 'set -x' turns on command exec logging " \ + "and that it behaves as defined by the standard" +} +set_x_body() { + test_option_on_off x + + # check that cmd output appears after -x is enabled + atf_check -s exit:0 \ + -o match:OKOK -o not-match:echo -o not-match:printf \ + -e not-match:printf -e match:OK -e match:echo \ + ${TEST_SH} -ec 'printf "%s" OK; set -x; echo OK; exit 0' + + # and that it stops again afer -x is disabled + atf_check -s exit:0 \ + -o match:OKOK -o not-match:echo -o not-match:printf \ + -e match:printf -e match:OK -e not-match:echo \ + ${TEST_SH} -ec 'set -x; printf "%s" OK; set +x; echo OK; exit 0' + + # also check that PS4 is output correctly + atf_check -s exit:0 \ + -o match:OK -o not-match:echo \ + -e match:OK -e match:Run:echo \ + ${TEST_SH} -ec 'PS4=Run:; set -x; echo OK; exit 0' + + return 0 + + # This one seems controversial... I suspect it is NetBSD's sh + # that is wrong to not output "for" "while" "if" ... etc + + # and lastly, that shell keywords do not get output when "executed" + atf_check -s exit:0 \ + -o match:111222333 -o not-match:printf \ + -o not-match:for \ + -e match:printf -e match:111 -e not-match:111222 \ + -e not-match:for -e not-match:do -e not-match:done \ + ${TEST_SH} -ec \ + 'set -x; for i in 111 222 333; do printf "%s" $i; done; echo; exit 0' +} + +opt_test_setup() +{ + test -n "$1" || { echo >&2 "Internal error"; exit 1; } + + cat > "$1" << 'END_OF_FUNCTIONS' +local_opt_check() +{ + local - +} + +instr() +{ + expr "$2" : "\(.*$1\)" >/dev/null +} + +save_opts() +{ + local - + + set -e + set -u + + instr e "$-" && instr u "$-" && return 0 + echo ERR +} + +fiddle_opts() +{ + set -e + set -u + + instr e "$-" && instr u "$-" && return 0 + echo ERR +} + +local_test() +{ + set +eu + + save_opts + instr '[eu]' "$-" || printf %s "OK" + + fiddle_opts + instr e "$-" && instr u "$-" && printf %s "OK" + + set +eu +} +END_OF_FUNCTIONS +} + +atf_test_case restore_local_opts +restore_local_opts_head() { + atf_set "descr" "Tests that 'local -' saves and restores options. " \ + "Note that "local" is a local shell addition" +} +restore_local_opts_body() { + atf_require_prog cat + atf_require_prog expr + + FN="test-funcs.$$" + opt_test_setup "${FN}" || atf_skip "Cannot setup test environment" + + ${TEST_SH} -ec ". './${FN}'; local_opt_check" 2>/dev/null || + atf_skip "sh extension 'local -' not supported by ${TEST_SH}" + + atf_check -s exit:0 -o match:OKOK -o not-match:ERR -e empty \ + ${TEST_SH} -ec ". './${FN}'; local_test" +} + +atf_test_case vi_emacs_VE_toggle +vi_emacs_VE_toggle_head() { + atf_set "descr" "Tests enabling vi disables emacs (and v.v - but why?)"\ + " Note that -V and -E are local shell additions" +} +vi_emacs_VE_toggle_body() { + + test_optional_on_off V E || + atf_skip "One or both V & E opts unsupported by ${TEST_SH}" + + atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c ' + q() { + eval "case \"$-\" in + (*${2}*) return 1;; + (*${1}*) return 0;; + esac" + return 1 + } + x() { + echo >&2 "Option set or toggle failure:" \ + " on=$1 off=$2 set=$-" + exit 1 + } + set -V; q V E || x V E + set -E; q E V || x E V + set -V; q V E || x V E + set +EV; q "" "[VE]" || x "" VE + exit 0 + ' +} + +atf_test_case xx_bogus +xx_bogus_head() { + atf_set "descr" "Tests that attempting to set a nonsense option fails." +} +xx_bogus_body() { + # Biggest problem here is picking a "nonsense option" that is + # not implemented by any shell, anywhere. Hopefully this will do. + + # 'set' is a special builtin, so a conforming shell should exit + # on an arg error, and the ERR should not be printed. + atf_check -s not-exit:0 -o empty -e not-empty \ + ${TEST_SH} -c 'set -% ; echo ERR' +} + +atf_test_case Option_switching +Option_switching_head() { + atf_set "descr" "options can be enabled and disabled" +} +Option_switching_body() { + + # Cannot test -m, setting it causes test shell to fail... + # (test shell gets SIGKILL!) Wonder why ... something related to atf + # That is, it works if just run as "sh -c 'echo $-; set -m; echo $-'" + + # Don't bother testing toggling -n, once on, it stays on... + # (and because the test fn refuses to allow us to try) + + # Cannot test -o or -c here, or the extension -s + # they can only be used, not switched + + # these are the posix options, that all shells should implement + test_option_on_off a b C e f h u v x # m + + # and these are extensions that might not exist (non-fatal to test) + # -i and -s (and -c) are posix options, but are not required to + # be accessable via the "set" command, just the command line. + # We allow for -i to work with set, as that makes some sense, + # -c and -s do not. + test_optional_on_off E i I p q V || true + + # Also test (some) option combinations ... + # only testing posix options here, because it is easier... + test_option_on_off aeu vx Ca aCefux +} + +atf_init_test_cases() { + # tests are run in order sort of names produces, so choose names wisely + + # this one tests turning on/off all the mandatory. and extra flags + atf_add_test_case Option_switching + # and this tests the NetBSD "local -" functionality in functions. + atf_add_test_case restore_local_opts + + # no tests for -m (no idea how to do that one) + # -I (no easy way to generate the EOF it ignores) + # -i (not sure how to test that one at the minute) + # -p (because we aren't going to run tests setuid) + # -V/-E (too much effort, and a real test would be huge) + # -c (because almost all the other tests test it anyway) + # -q (because, for now, I am lazy) + # -s (coming soon, hopefully) + # -o (really +o: again, hopefully soon) + # -o longname (again, just laziness, don't wait...) + # -h/-b (because NetBSD doesn't implement them) + atf_add_test_case set_a + atf_add_test_case set_C + atf_add_test_case set_e + atf_add_test_case set_f + atf_add_test_case set_n + atf_add_test_case set_u + atf_add_test_case set_v + atf_add_test_case set_x + + atf_add_test_case vi_emacs_VE_toggle + atf_add_test_case xx_bogus +} diff --git a/contrib/netbsd-tests/bin/sh/t_redir.sh b/contrib/netbsd-tests/bin/sh/t_redir.sh new file mode 100755 index 0000000..580de88 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_redir.sh @@ -0,0 +1,903 @@ +# $NetBSD: t_redir.sh,v 1.9 2016/05/14 00:33:02 kre Exp $ +# +# Copyright (c) 2016 The NetBSD Foundation, Inc. +# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# +# the implementation of "sh" to test +: ${TEST_SH:="/bin/sh"} + +# Any failures in this first test means it is not worth bothering looking +# for causes of failures in any other tests, make this one work first. + +# Problems with this test usually mean inadequate ATF_SHELL used for testing. +# (though if all pass but the last, it might be a TEST_SH problem.) + +atf_test_case basic_test_method_test +basic_test_method_test_head() +{ + atf_set "descr" "Tests that test method works as expected" +} +basic_test_method_test_body() +{ + cat <<- 'DONE' | + DONE + atf_check -s exit:0 -o empty -e empty ${TEST_SH} + cat <<- 'DONE' | + DONE + atf_check -s exit:0 -o match:0 -e empty ${TEST_SH} -c 'wc -l' + + cat <<- 'DONE' | + echo hello + DONE + atf_check -s exit:0 -o match:hello -e empty ${TEST_SH} + cat <<- 'DONE' | + echo hello + DONE + atf_check -s exit:0 -o match:1 -e empty ${TEST_SH} -c 'wc -l' + + cat <<- 'DONE' | + echo hello\ + world + DONE + atf_check -s exit:0 -o match:helloworld -e empty ${TEST_SH} + cat <<- 'DONE' | + echo hello\ + world + DONE + atf_check -s exit:0 -o match:2 -e empty ${TEST_SH} -c 'wc -l' + + printf '%s\n%s\n%s\n' Line1 Line2 Line3 > File + atf_check -s exit:0 -o inline:'Line1\nLine2\nLine3\n' -e empty \ + ${TEST_SH} -c 'cat File' + + cat <<- 'DONE' | + set -- X "" '' Y + echo ARGS="${#}" + echo '' -$1- -$2- -$3- -$4- + cat <File + + atf_check -s exit:0 -e empty \ + -o inline:'First Line\nSecond Line\nLine 3\nEND\n' \ + ${TEST_SH} -c 'cat < File' + atf_check -s exit:0 -e empty \ + -o inline:'First Line\nSecond Line\nLine 3\nEND\n' \ + ${TEST_SH} -c 'cat /dev/null || : + test -f Output && atf_fail "Unable to remove Output file" +#1 + i; atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c '> Output' + test -f Output || atf_fail "#$T: Did not make Output file" +#2 + rm -f Output 2>/dev/null || : + i; atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c '>> Output' + test -f Output || atf_fail "#$T: Did not make Output file" +#3 + rm -f Output 2>/dev/null || : + i; atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c '>| Output' + test -f Output || atf_fail "#$T: Did not make Output file" + +#4 + rm -f Output 2>/dev/null || : + i + atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c 'echo Hello >Output' + test -s Output || atf_fail "#$T: Did not make non-empty Output file" + test "$(cat Output)" = "Hello" || + atf_fail "#$T: Incorrect Output: Should be 'Hello' is '$(cat Output)'" +#5 + i + atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c 'echo Hello>!Output' + test -s Output || atf_fail "#$T: Did not make non-empty Output file" + test "$(cat Output)" = "Hello" || + atf_fail "#$T: Incorrect Output: Should be 'Hello' is '$(cat Output)'" +#6 + i + atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c 'echo Bye >>Output' + test -s Output || atf_fail "#$T: Removed Output file" + test "$(cat Output)" = "Hello${nl}Bye" || atf_fail \ + "#$T: Incorrect Output: Should be 'Hello\\nBye' is '$(cat Output)'" +#7 + i; atf_check -s exit:0 -o inline:'line 1\nline 2\n' -e empty \ + ${TEST_SH} -c \ + 'echo line 1 > Output; echo line 2 >> Output; cat Output' + test "$(cat Output)" = "line 1${nl}line 2" || atf_fail \ + "#$T: Incorrect Output: Should be 'line 1\\nline 2' is '$(cat Output)'" +#8 + i; atf_check -s exit:0 -o inline:'line 2\n' -e empty \ + ${TEST_SH} -c 'echo line 1 > Output; echo line 2' + test "$(cat Output)" = "line 1" || atf_fail \ + "#$T: Incorrect Output: Should be 'line 1' is '$(cat Output)'" +#9 + i; atf_check -s exit:0 -o empty -e empty \ + ${TEST_SH} -c '(echo line 1; echo line 2 > Out2) > Out1' + test "$(cat Out1)" = "line 1" || atf_fail \ + "#$T: Incorrect Out1: Should be 'line 1' is '$(cat Out1)'" + test "$(cat Out2)" = "line 2" || atf_fail \ + "#$T: Incorrect Out2: Should be 'line 2' is '$(cat Out2)'" +#10 + i; atf_check -s exit:0 -o empty -e empty \ + ${TEST_SH} -c '{ echo line 1; echo line 2 > Out2;} > Out1' + test "$(cat Out1)" = "line 1" || atf_fail \ + "#$T: Incorrect Out1: Should be 'line 1' is '$(cat Out1)'" + test "$(cat Out2)" = "line 2" || atf_fail \ + "#$T: Incorrect Out2: Should be 'line 2' is '$(cat Out2)'" +#11 + i; rm -f Out1 Out2 2>/dev/null || : + cat <<- 'EOF' | + for arg in 'line 1' 'line 2' 'line 3' + do + echo "$arg" + echo "$arg" > Out1 + done > Out2 + EOF + atf_check -s exit:0 -o empty -e empty ${TEST_SH} + test "$(cat Out1)" = "line 3" || atf_fail \ + "#$T: Incorrect Out1: Should be 'line 3' is '$(cat Out1)'" + test "$(cat Out2)" = "line 1${nl}line 2${nl}line 3" || atf_fail \ + "#$T: Incorrect Out2: Should be 'line 1\\nline 2\\nline 3' is '$(cat Out2)'" +#12 + i; rm -f Out1 Out2 2>/dev/null || : + cat <<- 'EOF' | + for arg in 'line 1' 'line 2' 'line 3' + do + echo "$arg" + echo "$arg" >> Out1 + done > Out2 + EOF + atf_check -s exit:0 -o empty -e empty ${TEST_SH} + test "$(cat Out1)" = "line 1${nl}line 2${nl}line 3" || atf_fail \ + "#$T: Incorrect Out1: Should be 'line 1\\nline 2\\nline 3' is '$(cat Out1)'" + test "$(cat Out2)" = "line 1${nl}line 2${nl}line 3" || atf_fail \ + "#$T: Incorrect Out2: Should be 'line 1\\nline 2\\nline 3' is '$(cat Out2)'" +} + +atf_test_case fd_redirections +fd_redirections_head() +{ + atf_set "descr" "Tests redirections to/from specific descriptors" +} +fd_redirections_body() +{ + atf_require_prog /bin/echo + + cat <<- 'DONE' > helper.sh + f() { + /bin/echo nothing "$1" >& "$1" + } + for n + do + eval "f $n $n"'> file-$n' + done + DONE + cat <<- 'DONE' > reread.sh + f() { + (read -r var; echo "${var}") <&"$1" + } + for n + do + x=$( eval "f $n $n"'< file-$n' ) + test "${x}" = "nothing $n" || echo "$n" + done + DONE + + validate() + { + for n + do + test -e "file-$n" || atf_fail "file-$n not created" + C=$(cat file-"$n") + test "$C" = "nothing $n" || + atf_fail "file-$n contains '$C' not 'nothing $n'" + done + } + + atf_check -s exit:0 -e empty -o empty \ + ${TEST_SH} helper.sh 1 2 3 4 5 6 7 8 9 + validate 1 2 3 4 5 6 7 8 9 + atf_check -s exit:0 -e empty -o empty \ + ${TEST_SH} reread.sh 3 4 5 6 7 8 9 + + L=$(ulimit -n) + if [ "$L" -ge 30 ] + then + atf_check -s exit:0 -e empty -o empty \ + ${TEST_SH} helper.sh 10 15 19 20 25 29 + validate 10 15 19 20 25 29 + atf_check -s exit:0 -e empty -o empty \ + ${TEST_SH} reread.sh 10 15 19 20 25 29 + fi + if [ "$L" -ge 100 ] + then + atf_check -s exit:0 -e empty -o empty \ + ${TEST_SH} helper.sh 32 33 49 50 51 63 64 65 77 88 99 + validate 32 33 49 50 51 63 64 65 77 88 99 + atf_check -s exit:0 -e empty -o empty \ + ${TEST_SH} reread.sh 32 33 49 50 51 63 64 65 77 88 99 + fi + if [ "$L" -ge 500 ] + then + atf_check -s exit:0 -e empty -o empty \ + ${TEST_SH} helper.sh 100 101 199 200 222 333 444 499 + validate 100 101 199 200 222 333 444 499 + atf_check -s exit:0 -e empty -o empty \ + ${TEST_SH} reread.sh 100 101 199 200 222 333 444 499 + fi + if [ "$L" -gt 1005 ] + then + atf_check -s exit:0 -e empty -o empty \ + ${TEST_SH} helper.sh 1000 1001 1002 1003 1004 1005 + validate 1000 1001 1002 1003 1004 1005 + atf_check -s exit:0 -e empty -o empty \ + ${TEST_SH} reread.sh 1000 1001 1002 1003 1004 1005 + fi +} + +atf_test_case local_redirections +local_redirections_head() +{ + atf_set "descr" \ + "Tests that exec can reassign file descriptors in the shell itself" +} +local_redirections_body() +{ + cat <<- 'DONE' > helper.sh + for f + do + eval "exec $f"'> file-$f' + done + + for f + do + printf '%s\n' "Hello $f" >&"$f" + done + + for f + do + eval "exec $f"'>&-' + done + + for f + do + eval "exec $f"'< file-$f' + done + + for f + do + exec <& "$f" + read -r var || echo >&2 "No data in file-$f" + read -r x && echo >&2 "Too much data in file-${f}: $x" + test "${var}" = "Hello $f" || + echo >&2 "file-$f contains '${var}' not 'Hello $f'" + done + DONE + + atf_check -s exit:0 -o empty -e empty \ + ${TEST_SH} helper.sh 3 4 5 6 7 8 9 + + L=$(ulimit -n) + if [ "$L" -ge 30 ] + then + atf_check -s exit:0 -o empty -e empty \ + ${TEST_SH} helper.sh 10 11 13 15 16 19 20 28 29 + fi + if [ "$L" -ge 100 ] + then + atf_check -s exit:0 -o empty -e empty \ + ${TEST_SH} helper.sh 30 31 32 63 64 65 77 88 99 + fi + if [ "$L" -ge 500 ] + then + atf_check -s exit:0 -o empty -e empty \ + ${TEST_SH} helper.sh 100 101 111 199 200 201 222 333 499 + fi + if [ "$L" -ge 1005 ] + then + atf_check -s exit:0 -o empty -e empty \ + ${TEST_SH} helper.sh 1000 1001 1002 1003 1004 1005 + fi +} + +atf_test_case named_fd_redirections +named_fd_redirections_head() +{ + atf_set "descr" "Tests redirections to /dev/stdout (etc)" + +} +named_fd_redirections_body() +{ + if test -c /dev/stdout + then + atf_check -s exit:0 -o inline:'OK\n' -e empty \ + ${TEST_SH} -c 'echo OK >/dev/stdout' + atf_check -s exit:0 -o inline:'OK\n' -e empty \ + ${TEST_SH} -c '/bin/echo OK >/dev/stdout' + fi + + if test -c /dev/stdin + then + atf_require_prog cat + + echo GOOD | atf_check -s exit:0 -o inline:'GOOD\n' -e empty \ + ${TEST_SH} -c 'read var /dev/stderr >&2' + atf_check -s exit:0 -e inline:'OK\n' -o empty \ + ${TEST_SH} -c '/bin/echo OK 2>/dev/stderr >&2' + fi + + if test -c /dev/fd/8 && test -c /dev/fd/9 + then + atf_check -s exit:0 -o inline:'EIGHT\n' -e empty \ + ${TEST_SH} -c 'printf "%s\n" EIGHT 8>&1 >/dev/fd/8 | + cat 9<&0 foo;; esac' + + atf_check -s exit:0 -o empty -e empty \ + ${TEST_SH} -c 'case x in (whatever) >foo 2>&1;; esac' + + atf_check -s exit:0 -o empty -e empty \ + ${TEST_SH} -c 'case x in (whatever) >foo 2>&1 ${somewhere};; esac' +} + +atf_test_case incorrect_redirections +incorrect_redirections_head() +{ + atf_set "descr" "Tests that sh(1) correctly ignores non-redirections" +} +incorrect_redirections_body() { + + atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c 'echo foo>' + atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c 'read foo<' + atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c 'echo foo<>' + atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \ + 'echo x > '"$nl" + atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \ + 'read x < '"$nl" + atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \ + 'echo x <> '"$nl" + atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \ + 'echo x >< anything' + atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \ + 'echo x >>< anything' + atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \ + 'echo x >|< anything' + atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \ + 'echo x > ; read x < /dev/null || echo bad' + atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \ + 'read x < & echo y > /dev/null; wait && echo bad' + + rm -f Output 2>/dev/null || : + atf_check -s exit:0 -e empty -o inline:'A Line > Output\n' \ + ${TEST_SH} -c 'echo A Line \> Output' + test -f Output && atf_file "File 'Output' appeared and should not have" + + rm -f Output 2>/dev/null || : + atf_check -s exit:0 -e empty -o empty \ + ${TEST_SH} -c 'echo A Line \>> Output' + test -f Output || atf_file "File 'Output' not created when it should" + test "$(cat Output)" = 'A Line >' || atf_fail \ + "Output file contains '$(cat Output)' instead of '"'A Line >'\' + + rm -f Output \> 2>/dev/null || : + atf_check -s exit:0 -e empty -o empty \ + ${TEST_SH} -c 'echo A Line >\> Output' + test -f Output && atf_file "File 'Output' appeared and should not have" + test -f '>' || atf_file "File '>' not created when it should" + test "$(cat '>')" = 'A Line Output' || atf_fail \ + "Output file ('>') contains '$(cat '>')' instead of 'A Line Output'" +} + +# Many more tests in t_here, so here we have just rudimentary checks +atf_test_case redir_here_doc +redir_here_doc_head() +{ + atf_set "descr" "Tests that sh(1) correctly processes 'here' doc " \ + "input redirections" +} +redir_here_doc_body() +{ + # nb: the printf is not executed, it is data + cat <<- 'DONE' | + cat <output-file + + ( printf "hello\n" >&6 ) + + exec 8&2 Hello ) + + ( printf "bye-bye\n" >&6 ) + + ( exec 8<&- ) + read bye <&8 || echo >&2 "Closed?" + echo Bye="$bye" + DONE + atf_check -s exit:0 -o match:Bye=bye-bye -e empty \ + ${TEST_SH} + + cat <<- 'DONE' | + for arg in one-4 two-24 three-14 + do + fd=${arg#*-} + file=${arg%-*} + eval "exec ${fd}>${file}" + done + + for arg in one-5 two-7 three-19 + do + fd=${arg#*-} + file=${arg%-*} + eval "exec ${fd}<${file}" + done + + ( + echo line-1 >&4 + echo line-2 >&24 + echo line-3 >&14 + echo go + ) | ( + read go + read x <&5 + read y <&7 + read z <&19 + + printf "%s\n" "${x}" "${y}" "${z}" + ) + DONE + atf_check -s exit:0 -o inline:'line-1\nline-2\nline-3\n' \ + -e empty ${TEST_SH} + + cat <<- 'DONE' | + for arg in one-4-5 two-6-7 three-8-9 four-11-10 five-3-12 + do + ofd=${arg##*-} + file=${arg%-*} + ifd=${file#*-} + file=${file%-*} + eval "exec ${ofd}>${file}" + eval "exec ${ifd}<${file}" + done + + ( ( ( echo line-1 >& 13 ) 13>&12 ) 12>&5 ) >stdout 2>errout + ( ( ( echo line-2 >& 4) 13>&12 ) 4>&7 ) >>stdout 2>>errout + ( ( ( echo line-3 >& 6) 8>&1 6>&11 >&12) 11>&9 >&7 ) >>stdout + + ( ( ( cat <&13 >&12 ) 13<&8 12>&10 ) 10>&1 8<&6 ) 6<&4 + ( ( ( cat <&4 ) <&4 6<&8 8<&11 ) + <&4 4<&6 6<&8 8<&11 ) <&4 4<&6 6<&8 8<&11 11<&3 + ( ( ( cat <&7 >&1 ) 7<&6 >&10 ) 10>&2 6<&8 ) 2>&1 + DONE + atf_check -s exit:0 -o inline:'line-1\nline-2\nline-3\n' \ + -e empty ${TEST_SH} +} + +atf_test_case ulimit_redirection_interaction +ulimit_redirection_interaction_head() +{ + atf_set "descr" "Tests interactions between redirect and ulimit -n " +} +ulimit_redirection_interaction_body() +{ + atf_require_prog ls + + cat <<- 'DONE' > helper.sh + oLIM=$(ulimit -n) + HRD=$(ulimit -H -n) + test "${oLIM}" -lt "${HRD}" && ulimit -n "${HRD}" + LIM=$(ulimit -n) + + FDs= + LFD=-1 + while [ ${LIM} -gt 16 ] + do + FD=$(( ${LIM} - 1 )) + if [ "${FD}" -eq "${LFD}" ]; then + echo >&2 "Infinite loop... (busted $(( )) ??)" + exit 1 + fi + LFD="${FD}" + + eval "exec ${FD}"'> /dev/null' + FDs="${FD}${FDs:+ }${FDs}" + + ( + FD=$(( ${LIM} + 1 )) + eval "exec ${FD}"'> /dev/null' + echo "Reached unreachable command" + ) 2>/dev/null && echo >&2 "Opened beyond limit!" + + (eval 'ls 2>&1 3>&1 4>&1 5>&1 '"${FD}"'>&1') >&"${FD}" + + LIM=$(( ${LIM} / 2 )) + ulimit -S -n "${LIM}" + done + + # Even though ulimit has been reduced, open fds should work + for FD in ${FDs} + do + echo ${FD} in ${FDs} >&"${FD}" || exit 1 + done + + ulimit -S -n "${oLIM}" + + # maybe more later... + + DONE + + atf_check -s exit:0 -o empty -e empty ${TEST_SH} helper.sh +} + +atf_test_case validate_fn_redirects +validate_fn_redirects_head() +{ + # These test cases inspired by PR bin/48875 and the sh + # changes that were required to fix it. + + atf_set "descr" "Tests various redirections applied to functions " \ + "See PR bin/48875" +} +validate_fn_redirects_body() +{ + cat <<- 'DONE' > f-def + f() { + printf '%s\n' In-Func + } + DONE + + atf_check -s exit:0 -o inline:'In-Func\nsuccess1\n' -e empty \ + ${TEST_SH} -c ". ./f-def; f ; printf '%s\n' success1" + atf_check -s exit:0 -o inline:'success2\n' -e empty \ + ${TEST_SH} -c ". ./f-def; f >/dev/null; printf '%s\n' success2" + atf_check -s exit:0 -o inline:'success3\n' -e empty \ + ${TEST_SH} -c ". ./f-def; f >&- ; printf '%s\n' success3" + atf_check -s exit:0 -o inline:'In-Func\nsuccess4\n' -e empty \ + ${TEST_SH} -c ". ./f-def; f & wait; printf '%s\n' success4" + atf_check -s exit:0 -o inline:'success5\n' -e empty \ + ${TEST_SH} -c ". ./f-def; f >&- & wait; printf '%s\n' success5" + atf_check -s exit:0 -o inline:'In-Func\nIn-Func\nsuccess6\n' -e empty \ + ${TEST_SH} -c ". ./f-def; f;f; printf '%s\n' success6" + atf_check -s exit:0 -o inline:'In-Func\nIn-Func\nsuccess7\n' -e empty \ + ${TEST_SH} -c ". ./f-def; { f;f;}; printf '%s\n' success7" + atf_check -s exit:0 -o inline:'In-Func\nIn-Func\nsuccess8\n' -e empty \ + ${TEST_SH} -c ". ./f-def; { f;f;}& wait; printf '%s\n' success8" + atf_check -s exit:0 -o inline:'In-Func\nsuccess9\n' -e empty \ + ${TEST_SH} -c \ + ". ./f-def; { f>/dev/null;f;}& wait; printf '%s\n' success9" + atf_check -s exit:0 -o inline:'In-Func\nsuccess10\n' -e empty \ + ${TEST_SH} -c \ + ". ./f-def; { f;f>/dev/null;}& wait; printf '%s\n' success10" + + # This one tests the issue etcupdate had with the original 48875 fix + atf_check -s exit:0 -o inline:'Func a\nFunc b\nFunc c\n' -e empty \ + ${TEST_SH} -c ' + f() { + echo Func "$1" + } + exec 3<&0 4>&1 + ( echo x-a; echo y-b; echo z-c ) | + while read A + do + B=${A#?-} + f "$B" <&3 >&4 + done >&2' + + # And this tests a similar condition with that same fix + cat <<- 'DONE' >Script + f() { + printf '%s' " hello $1" + } + exec 3>&1 + echo $( for i in a b c + do printf '%s' @$i; f $i >&3; done >foo + ) + printf '%s\n' foo=$(cat foo) + DONE + atf_check -s exit:0 -e empty \ + -o inline:' hello a hello b hello c\nfoo=@a@b@c\n' \ + ${TEST_SH} Script + + # Tests with sh reading stdin, which is not quite the same internal + # mechanism. + echo ". ./f-def || echo >&2 FAIL + f + printf '%s\n' stdin1 + "| atf_check -s exit:0 -o inline:'In-Func\nstdin1\n' -e empty ${TEST_SH} + + echo ' + . ./f-def || echo >&2 FAIL + f >&- + printf "%s\n" stdin2 + ' | atf_check -s exit:0 -o inline:'stdin2\n' -e empty ${TEST_SH} + + cat <<- 'DONE' > fgh.def + f() { + echo -n f >&3 + sleep 4 + echo -n F >&3 + } + g() { + echo -n g >&3 + sleep 2 + echo -n G >&3 + } + h() { + echo -n h >&3 + } + DONE + + atf_check -s exit:0 -o inline:'fFgGh' -e empty \ + ${TEST_SH} -c '. ./fgh.def || echo >&2 FAIL + exec 3>&1 + f; g; h' + + atf_check -s exit:0 -o inline:'fghGF' -e empty \ + ${TEST_SH} -c '. ./fgh.def || echo >&2 FAIL + exec 3>&1 + f & sleep 1; g & sleep 1; h; wait' + + atf_check -s exit:0 -o inline:'fFgGhX Y\n' -e empty \ + ${TEST_SH} -c '. ./fgh.def || echo >&2 FAIL + exec 3>&1 + echo X $( f ; g ; h ) Y' + + # This one is the real test for PR bin/48875. If the + # cmdsub does not complete before f g (and h) exit, + # then the 'F' & 'G' will precede 'X Y' in the output. + # If the cmdsub finishes while f & g are still running, + # then the X Y will appear before the F and G. + # The trailing "sleep 3" is just so we catch all the + # output (otherwise atf_check will be finished while + # f & g are still sleeping). + + atf_check -s exit:0 -o inline:'fghX Y\nGF' -e empty \ + ${TEST_SH} -c '. ./fgh.def || echo >&2 FAIL + exec 3>&1 + echo X $( f >&- & sleep 1; g >&- & sleep 1 ; h ) Y + sleep 3 + exec 4>&1 || echo FD_FAIL + ' + + # Do the test again to verify it also all works reading stdin + # (which is a slightly different path through the shell) + echo ' + . ./fgh.def || echo >&2 FAIL + exec 3>&1 + echo X $( f >&- & sleep 1; g >&- & sleep 1 ; h ) Y + sleep 3 + exec 4>&1 || echo FD_FAIL + ' | atf_check -s exit:0 -o inline:'fghX Y\nGF' -e empty ${TEST_SH} +} + +atf_init_test_cases() { + atf_add_test_case basic_test_method_test + atf_add_test_case do_input_redirections + atf_add_test_case do_output_redirections + atf_add_test_case fd_redirections + atf_add_test_case local_redirections + atf_add_test_case incorrect_redirections + atf_add_test_case named_fd_redirections + atf_add_test_case redir_here_doc + atf_add_test_case redir_in_case + atf_add_test_case subshell_redirections + atf_add_test_case ulimit_redirection_interaction + atf_add_test_case validate_fn_redirects +} diff --git a/contrib/netbsd-tests/bin/sh/t_redircloexec.sh b/contrib/netbsd-tests/bin/sh/t_redircloexec.sh new file mode 100755 index 0000000..7659606 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_redircloexec.sh @@ -0,0 +1,178 @@ +# $NetBSD: t_redircloexec.sh,v 1.3 2016/05/15 15:44:43 kre Exp $ +# +# Copyright (c) 2016 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Christos Zoulas. +# +# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# +# the implementation of "sh" to test +: ${TEST_SH:="/bin/sh"} + +mkhelper() { + name=$1 + fd=$2 + shift 2 + + echo "$@" > ./"${name}1" + echo "echo ${name}2" ">&${fd}" > ./"${name}2" +} + +runhelper() { + ${TEST_SH} "./${1}1" +} + +cleanhelper() { + # not really needed, atf cleans up... + rm -f ./"${1}1" ./"${1}2" out +} + +atf_test_case exec_redir_closed +exec_redir_closed_head() { + atf_set "descr" "Tests that redirections created by exec are closed on exec" +} +exec_redir_closed_body() { + + mkhelper exec 6 \ + "exec 6> out; echo exec1 >&6; ${TEST_SH} exec2; exec 6>&-" + + atf_check -s exit:0 -o empty -e not-empty ${TEST_SH} ./exec1 + atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -e ./exec1 + + mkhelper exec 9 \ + "exec 9> out; echo exec1 >&9; ${TEST_SH} exec2" + + atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} ./exec1 + + mkhelper exec 8 \ + "exec 8> out; printf OK; echo exec1 >&8;" \ + "printf OK; ${TEST_SH} exec2; printf ERR" + + atf_check -s not-exit:0 -o match:OKOK -o not-match:ERR -e not-empty \ + ${TEST_SH} -e ./exec1 + + mkhelper exec 7 \ + "exec 7> out; printf OK; echo exec1 >&7;" \ + "printf OK; ${TEST_SH} exec2 || printf ERR" + + atf_check -s exit:0 -o match:OKOKERR -e not-empty \ + ${TEST_SH} ./exec1 + + cleanhelper exec +} + +atf_test_case exec_redir_open +exec_redir_open_head() { + atf_set "descr" "Tests that redirections created by exec can remain open" +} +exec_redir_open_body() { + + mkhelper exec 6 \ + "exec 6> out 6>&6; echo exec1 >&6; ${TEST_SH} exec2; exec 6>&-" + + atf_check -s exit:0 -o empty -e empty ${TEST_SH} ./exec1 + atf_check -s exit:0 -o empty -e empty ${TEST_SH} -e ./exec1 + + mkhelper exec 9 \ + "exec 9> out ; echo exec1 >&9; ${TEST_SH} exec2 9>&9" + + atf_check -s exit:0 -o empty -e empty ${TEST_SH} ./exec1 + + mkhelper exec 8 \ + "exec 8> out; printf OK; exec 8>&8; echo exec1 >&8;" \ + "printf OK; ${TEST_SH} exec2; printf OK" + + atf_check -s exit:0 -o match:OKOKOK -e empty \ + ${TEST_SH} -e ./exec1 + + mkhelper exec 7 \ + "exec 7> out; printf OK; echo exec1 >&7;" \ + "printf OK; ${TEST_SH} 7>&7 exec2; printf OK" + + atf_check -s exit:0 -o match:OKOKOK -e empty \ + ${TEST_SH} -e ./exec1 + + cleanhelper exec +} + +atf_test_case loop_redir_open +loop_redir_open_head() { + atf_set "descr" "Tests that redirections in loops don't close on exec" +} +loop_redir_open_body() { + mkhelper for 3 "for x in x; do ${TEST_SH} ./for2; done 3>out" + atf_check -s exit:0 \ + -o empty \ + -e empty \ + ${TEST_SH} ./for1 + cleanhelper for +} + +atf_test_case compound_redir_open +compound_redir_open_head() { + atf_set "descr" "Tests that redirections in compound statements don't close on exec" +} +compound_redir_open_body() { + mkhelper comp 3 "{ ${TEST_SH} ./comp2; } 3>out" + atf_check -s exit:0 \ + -o empty \ + -e empty \ + ${TEST_SH} ./comp1 + cleanhelper comp +} + +atf_test_case simple_redir_open +simple_redir_open_head() { + atf_set "descr" "Tests that redirections in simple commands don't close on exec" +} +simple_redir_open_body() { + mkhelper simp 4 "${TEST_SH} ./simp2 4>out" + atf_check -s exit:0 \ + -o empty \ + -e empty \ + ${TEST_SH} ./simp1 + cleanhelper simp +} + +atf_test_case subshell_redir_open +subshell_redir_open_head() { + atf_set "descr" "Tests that redirections on subshells don't close on exec" +} +subshell_redir_open_body() { + mkhelper comp 5 "( ${TEST_SH} ./comp2; ${TEST_SH} ./comp2 ) 5>out" + atf_check -s exit:0 \ + -o empty \ + -e empty \ + ${TEST_SH} ./comp1 + cleanhelper comp +} + +atf_init_test_cases() { + atf_add_test_case exec_redir_closed + atf_add_test_case exec_redir_open + atf_add_test_case loop_redir_open + atf_add_test_case compound_redir_open + atf_add_test_case simple_redir_open + atf_add_test_case subshell_redir_open +} diff --git a/contrib/netbsd-tests/bin/sh/t_set_e.sh b/contrib/netbsd-tests/bin/sh/t_set_e.sh index 8dfe6e4..b56ab22 100755 --- a/contrib/netbsd-tests/bin/sh/t_set_e.sh +++ b/contrib/netbsd-tests/bin/sh/t_set_e.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_set_e.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# $NetBSD: t_set_e.sh,v 1.4 2016/03/31 16:22:27 christos Exp $ # # Copyright (c) 2007 The NetBSD Foundation, Inc. # All rights reserved. @@ -30,7 +30,7 @@ # http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html # the implementation of "sh" to test -: ${TEST_SH:="sh"} +: ${TEST_SH:="/bin/sh"} failwith() { @@ -63,7 +63,7 @@ dcheck() # is thus important to test. (PR bin/29861) echeck() { - check1 'eval '"'($1)'" "$2" "eval '($1)'" + check1 'eval '"'( $1 )'" "$2" "eval '($1)'" } atf_test_case all @@ -81,8 +81,8 @@ all_body() { # first, check basic functioning. # The ERR shouldn't print; the result of the () should be 1. # Henceforth we'll assume that we don't need to check $?. - dcheck '(set -e; false; echo ERR$?); echo -n OK$?' 'OK1' - echeck '(set -e; false; echo ERR$?); echo -n OK$?' 'OK1' + dcheck '(set -e; false; echo ERR$?); echo OK$?' 'OK1' + echeck '(set -e; false; echo ERR$?); echo OK$?' 'OK1' # these cases should be equivalent to the preceding. dcheck '(set -e; /nonexistent; echo ERR); echo OK' 'OK' @@ -205,6 +205,9 @@ all_body() { # According to dsl@ in PR bin/32282, () is not defined as a # subshell, only as a grouping operator [and a scope, I guess] + + # (This is incorrect. () is definitely a sub-shell) + # so the nested false ought to cause the whole shell to exit, # not just the subshell. dholland@ would like to see C&V, # because that seems like a bad idea. (Among other things, it @@ -215,8 +218,10 @@ all_body() { # # XXX: the second set has been disabled in the name of making # all tests "pass". + # + # As they should be, they are utter nonsense. - # 1. error if the whole shell exits (current behavior) + # 1. error if the whole shell exits (current correct behavior) dcheck 'echo OK; (set -e; false); echo OK' 'OK OK' echeck 'echo OK; (set -e; false); echo OK' 'OK OK' # 2. error if the whole shell does not exit (dsl's suggested behavior) @@ -232,29 +237,32 @@ all_body() { # backquote expansion (PR bin/17514) - # correct + # (in-)correct #dcheck '(set -e; echo ERR `false`; echo ERR); echo OK' 'OK' #dcheck '(set -e; echo ERR $(false); echo ERR); echo OK' 'OK' #dcheck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'OK' #dcheck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'OK' - # wrong current behavior + # Not-wrong current behavior + # the exit status of ommand substitution is ignored in most cases + # None of these should be causing the shell to exit. dcheck '(set -e; echo ERR `false`; echo ERR); echo OK' 'ERR ERR OK' dcheck '(set -e; echo ERR $(false); echo ERR); echo OK' 'ERR ERR OK' dcheck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'ERR ERR OK' dcheck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'ERR ERR OK' + # This is testing one case (the case?) where the exit status is used dcheck '(set -e; x=`false`; echo ERR); echo OK' 'OK' dcheck '(set -e; x=$(false); echo ERR); echo OK' 'OK' dcheck '(set -e; x=`exit 3`; echo ERR); echo OK' 'OK' dcheck '(set -e; x=$(exit 3); echo ERR); echo OK' 'OK' - # correct + # correct (really just commented out incorrect nonsense) #echeck '(set -e; echo ERR `false`; echo ERR); echo OK' 'OK' #echeck '(set -e; echo ERR $(false); echo ERR); echo OK' 'OK' #echeck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'OK' #echeck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'OK' - # wrong current behavior + # not-wrong current behavior (as above) echeck '(set -e; echo ERR `false`; echo ERR); echo OK' 'ERR ERR OK' echeck '(set -e; echo ERR $(false); echo ERR); echo OK' 'ERR ERR OK' echeck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'ERR ERR OK' @@ -267,11 +275,19 @@ all_body() { # shift (PR bin/37493) # correct + # Actually, both ways are correct, both are permitted #dcheck '(set -e; shift || true; echo OK); echo OK' 'OK OK' #echeck '(set -e; shift || true; echo OK); echo OK' 'OK OK' - # wrong current behavior - dcheck '(set -e; shift || true; echo OK); echo OK' 'OK' - echeck '(set -e; shift || true; echo OK); echo OK' 'OK' + # (not-) wrong current behavior + #dcheck '(set -e; shift || true; echo OK); echo OK' 'OK' + #echeck '(set -e; shift || true; echo OK); echo OK' 'OK' + + # what is wrong is this test assuming one behaviour or the other + # (and incidentally this has nothing whatever to do with "-e", + # the test should really be moved elsewhere...) + # But for now, leave it here, and correct it: + dcheck '(set -e; shift && echo OK); echo OK' 'OK' + echeck '(set -e; shift && echo OK); echo OK' 'OK' # Done. diff --git a/contrib/netbsd-tests/bin/sh/t_shift.sh b/contrib/netbsd-tests/bin/sh/t_shift.sh new file mode 100755 index 0000000..f65c6c2 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_shift.sh @@ -0,0 +1,181 @@ +# $NetBSD: t_shift.sh,v 1.2 2016/05/17 09:05:14 kre Exp $ +# +# Copyright (c) 2016 The NetBSD Foundation, Inc. +# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# +# the implementation of "sh" to test +: ${TEST_SH:="/bin/sh"} + +atf_test_case basic_shift_test +basic_shift_test_head() { + atf_set "descr" "Test correct operation of valid shifts" +} +basic_shift_test_body() { + + for a in \ + "one-arg::0:one-arg" \ + "one-arg:1:0:one-arg" \ + "one-arg:0:1 one-arg" \ + "a b c::2 b c:a" \ + "a b c:1:2 b c:a" \ + "a b c:2:1 c:a:b" \ + "a b c:3:0:a:b:c" \ + "a b c:0:3 a b c" \ + "a b c d e f g h i j k l m n o p:1:15 b c d e f g h i j k l m n o p"\ + "a b c d e f g h i j k l m n o p:9:7 j k l m n o p:a:b:c:g:h:i" \ + "a b c d e f g h i j k l m n o p:13:3 n o p:a:b:c:d:k:l:m" \ + "a b c d e f g h i j k l m n o p:16:0:a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p" + do + oIFS="${IFS}" + IFS=:; set -- $a + IFS="${oIFS}" + + init="$1"; n="$2"; res="$3"; shift 3 + + not= + for b + do + not="${not} -o not-match:$b" + done + + atf_check -s exit:0 -o "match:${res}" ${not} -e empty \ + ${TEST_SH} -c "set -- ${init}; shift $n;"' echo "$# $*"' + done + + atf_check -s exit:0 -o match:complete -o not-match:ERR -e empty \ + ${TEST_SH} -c \ + 'set -- a b c d e;while [ $# -gt 0 ];do shift||echo ERR;done;echo complete' +} + +atf_test_case excessive_shift +excessive_shift_head() { + atf_set "descr" "Test acceptable operation of shift too many" +} +# In: +# +# http://pubs.opengroup.org/onlinepubs/9699919799 +# /utilities/V3_chap02.html#tag_18_26_01 +# +# (that URL should be one line, with the /util... immediately after ...9799) +# +# POSIX says of shift (in the "EXIT STATUS" paragraph): +# +# If the n operand is invalid or is greater than "$#", this may be considered +# a syntax error and a non-interactive shell may exit; if the shell does not +# exit in this case, a non-zero exit status shall be returned. +# Otherwise, zero shall be returned. +# +# NetBSD's sh treats it as an error and exits (if non-interactive, as here), +# other shells do not. +# +# Either behaviour is acceptable - so the test allows for both +# (and checks that if the shell does not exit, "shift" returns status != 0) + +excessive_shift_body() { + for a in \ + "one-arg:2" \ + "one-arg:4" \ + "one-arg:13" \ + "one two:3" \ + "one two:7" \ + "one two three four five:6" \ + "I II III IV V VI VII VIII IX X XI XII XIII XIV XV:16" \ + "I II III IV V VI VII VIII IX X XI XII XIII XIV XV:17" \ + "I II III IV V VI VII VIII IX X XI XII XIII XIV XV:30" \ + "I II III IV V VI VII VIII IX X XI XII XIII XIV XV:9999" + do + oIFS="${IFS}" + IFS=:; set -- $a + IFS="${oIFS}" + + atf_check -s not-exit:0 -o match:OK -o not-match:ERR \ + -e ignore ${TEST_SH} -c \ + "set -- $1 ;"'echo OK:$#-'"$2;shift $2 && echo ERR" + done +} + +atf_test_case function_shift +function_shift_head() { + atf_set "descr" "Test that shift in a function does not affect outside" +} +function_shift_body() { + : # later... +} + +atf_test_case non_numeric_shift +non_numeric_shift_head() { + atf_set "descr" "Test that non-numeric args to shift are detected" +} + +# from the DESCRIPTION section at the URL mentioned with the excessive_shift +# test: +# +# The value n shall be an unsigned decimal integer ... +# +# That is not hex (octal will be treated as if it were decimal, a leading 0 +# will simply be ignored - we test for this by giving an "octal" value that +# would be OK if parsed as octal, but not if parsed (correctly) as decimal) +# +# Obviously total trash like roman numerals or alphabetic strings are out. +# +# Also no signed values (no + or -) and not a string that looks kind of like +# a number, but only if you're generous +# +# But as the EXIT STATUS section quoted above says, with an invalid 'n' +# the shell has the option of exiting, or returning status != 0, so +# again this test allows both. + +non_numeric_shift_body() { + + # there are 9 args set, 010 is 8 if parsed octal, 10 decimal + for a in a I 0x12 010 5V -1 ' ' '' +1 ' 1' + do + atf_check -s not-exit:0 -o empty -e ignore ${TEST_SH} -c \ + "set -- a b c d e f g h i; shift '$a' && echo ERROR" + done +} + +atf_test_case too_many_args +too_many_args_head() { + # See PR bin/50896 + atf_set "descr" "Test that sh detects invalid extraneous args to shift" +} +# This is a syntax error, a non-interactive shell (us) must exit $? != 0 +too_many_args_body() { + # This tests the bug in PR bin/50896 is fixed + + for a in "1 1" "1 0" "1 2 3" "1 foo" "1 --" "-- 1" + do + atf_check -s not-exit:0 -o empty -e not-empty ${TEST_SH} -c \ + " set -- a b c d; shift ${a} ; echo FAILED " + done +} + +atf_init_test_cases() { + atf_add_test_case basic_shift_test + atf_add_test_case excessive_shift + atf_add_test_case function_shift + atf_add_test_case non_numeric_shift + atf_add_test_case too_many_args +} diff --git a/contrib/netbsd-tests/bin/sh/t_ulimit.sh b/contrib/netbsd-tests/bin/sh/t_ulimit.sh index 3e7c0a6..094a2ee 100755 --- a/contrib/netbsd-tests/bin/sh/t_ulimit.sh +++ b/contrib/netbsd-tests/bin/sh/t_ulimit.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_ulimit.sh,v 1.1 2012/06/11 18:32:59 njoly Exp $ +# $NetBSD: t_ulimit.sh,v 1.3 2016/03/27 14:50:01 christos Exp $ # # Copyright (c) 2012 The NetBSD Foundation, Inc. # All rights reserved. @@ -24,6 +24,8 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # +# the implementation of "sh" to test +: ${TEST_SH:="/bin/sh"} # ulimit builtin test. @@ -31,13 +33,22 @@ atf_test_case limits limits_head() { atf_set "descr" "Checks for limits flags" } + +get_ulimits() { + local limits=$(${TEST_SH} -c 'ulimit -a' | + sed -e 's/.*\(-[A-Za-z0-9]\)[^A-Za-z0-9].*/\1/' | sort -u) + if [ -z "$limits" ]; then + # grr ksh + limits="-a -b -c -d -f -l -m -n -p -r -s -t -v" + fi + echo "$limits" +} + limits_body() { - atf_check -s eq:0 -o ignore -e empty \ - /bin/sh -c "ulimit -a" - for l in $(ulimit -a | sed 's,^.*(,,;s, .*$,,'); + atf_check -s eq:0 -o ignore -e empty ${TEST_SH} -c "ulimit -a" + for l in $(get_ulimits) do - atf_check -s eq:0 -o ignore -e empty \ - /bin/sh -c "ulimit $l" + atf_check -s eq:0 -o ignore -e empty ${TEST_SH} -c "ulimit $l" done } diff --git a/contrib/netbsd-tests/bin/sh/t_varquote.sh b/contrib/netbsd-tests/bin/sh/t_varquote.sh index 1768777..3811d85 100755 --- a/contrib/netbsd-tests/bin/sh/t_varquote.sh +++ b/contrib/netbsd-tests/bin/sh/t_varquote.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_varquote.sh,v 1.2 2012/03/25 18:50:19 christos Exp $ +# $NetBSD: t_varquote.sh,v 1.5 2016/03/27 14:50:01 christos Exp $ # # Copyright (c) 2007 The NetBSD Foundation, Inc. # All rights reserved. @@ -24,6 +24,8 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # +# the implementation of "sh" to test +: ${TEST_SH:="/bin/sh"} # Variable quoting test. @@ -39,30 +41,70 @@ all_head() { atf_set "descr" "Basic checks for variable quoting" } all_body() { - foo='${a:-foo}' - check "$foo" '${a:-foo}' - foo="${a:-foo}" - check "$foo" "foo" + cat <<-'EOF' > script.sh + T=0 + check() { + T=$((${T} + 1)) - foo=${a:-"'{}'"} - check "$foo" "'{}'" + if [ "$1" != "$2" ] + then + printf '%s\n' "T${T}: expected [$2], found [$1]" + exit 1 + fi + } - foo=${a:-${b:-"'{}'"}} - check "$foo" "'{}'" + #1 + foo='${a:-foo}' + check "$foo" '${a:-foo}' + #2 + foo="${a:-foo}" + check "$foo" "foo" + #3 + foo=${a:-"'{}'"} + check "$foo" "'{}'" + #4 + foo=${a:-${b:-"'{}'"}} + check "$foo" "'{}'" + #5 + # ${ } The ' are inside ".." so are literal (not quotes). + foo="${a-'}'}" + check "$foo" "''}" + #6 + # The rules for quoting in ${var-word} expressions are somewhat + # weird, in the following there is not one quoted string being + # assigned to foo (with internally quoted sub-strings), rather + # it is a mixed quoted/unquoted string, with parts that are + # quoted, separated by 2 unquoted sections... + # qqqqqqqqqq uuuuuuuuuu qq uuuu qqqq + foo="${a:-${b:-"${c:-${d:-"x}"}}y}"}}z}" + # " z*" + # ${a:- } + # ${b:- } + # " y*" + # ${c:- } + # ${d:- } + # "x*" + check "$foo" "x}y}z}" + #7 + # And believe it or not, this is the one that gives + # most problems, with 3 different observed outputs... + # qqqqq qq q is one interpretation + # qqqqq QQQQ q is another (most common) + # (the third is syntax error...) + foo="${a:-"'{}'"}" + check "$foo" "'{}'" - foo="${a:-"'{}'"}" - check "$foo" "'{}'" + EOF - foo="${a:-${b:-"${c:-${d:-"x}"}}y}"}}z}" - # " z*" - # ${a:- } - # ${b:- } - # " y*" - # ${c:- } - # ${d:- } - # "x*" - check "$foo" "x}y}z}" + OUT=$( ${TEST_SH} script.sh 2>&1 ) + if [ $? -ne 0 ] + then + atf_fail "${OUT}" + elif [ -n "${OUT}" ] + then + atf_fail "script.sh unexpectedly said: ${OUT}" + fi } atf_test_case nested_quotes_multiword @@ -72,10 +114,21 @@ nested_quotes_multiword_head() { } nested_quotes_multiword_body() { atf_check -s eq:0 -o match:"first-word second-word" -e empty \ - /bin/sh -c 'echo "${foo:="first-word"} second-word"' + ${TEST_SH} -c 'echo "${foo:="first-word"} second-word"' +} + +atf_test_case default_assignment_with_arith +default_assignment_with_arith_head() { + atf_set "descr" "Tests default variable assignment with arithmetic" \ + "string works (PR bin/50827)" +} +default_assignment_with_arith_body() { + atf_check -s eq:0 -o empty -e empty ${TEST_SH} -c ': "${x=$((1))}"' + atf_check -s eq:0 -o match:1 -e empty ${TEST_SH} -c 'echo "${x=$((1))}"' } atf_init_test_cases() { atf_add_test_case all atf_add_test_case nested_quotes_multiword + atf_add_test_case default_assignment_with_arith } diff --git a/contrib/netbsd-tests/bin/sh/t_varval.sh b/contrib/netbsd-tests/bin/sh/t_varval.sh new file mode 100755 index 0000000..94e306b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_varval.sh @@ -0,0 +1,251 @@ +# $NetBSD: t_varval.sh,v 1.1 2016/03/16 15:49:19 christos Exp $ +# +# Copyright (c) 2016 The NetBSD Foundation, Inc. +# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# +# the implementation of "sh" to test +: ${TEST_SH:="/bin/sh"} + +# Test all kinds of weird values in various ways to use shell $... expansions + +oneline() +{ + q="'" + test $# -eq 4 && q="" + + v=$( printf '\\%3.3o' $(( $2 & 0xFF )) ) + printf "%s" "$1" + if [ $2 != 39 ]; then + printf "%sprefix${v}suffix%s" "$q" "$q" + elif [ $# -ne 4 ]; then + printf %s prefix\"\'\"suffix + else + printf %s prefix\'suffix + fi + printf "%s\n" "$3" +} + +mkdata() { + quote= pfx= + while [ $# -gt 0 ] + do + case "$1" in + --) shift; break;; + -q) quote=no; shift; continue;; + esac + + pfx="${pfx}${pfx:+ }${1}" + shift + done + + sfx= + while [ $# -gt 0 ] + do + sfx="${sfx}${sfx:+ }${1}" + shift + done + + i=1 # '\0' is not expected to work, anywhere... + while [ $i -lt 256 ] + do + oneline "${pfx}" "$i" "${sfx}" $quote + i=$(( $i + 1 )) + done +} + +atf_test_case aaa +aaa_head() { + atf_set "descr" "Check that this test has a hope of working. " \ + "Just give up on these tests if the aaa test fails". +} +aaa_body() { + oneline "echo " 9 '' | + atf_check -s exit:0 -o inline:'prefix\tsuffix\n' -e empty \ + ${TEST_SH} + + oneline "VAR=" 65 '; echo "${#VAR}:${VAR}"' | + atf_check -s exit:0 -o inline:'13:prefixAsuffix\n' -e empty \ + ${TEST_SH} + + oneline "VAR=" 1 '; echo "${#VAR}:${VAR}"' | + atf_check -s exit:0 -o inline:'13:prefixsuffix\n' -e empty \ + ${TEST_SH} + + oneline "VAR=" 10 '; echo "${#VAR}:${VAR}"' | + atf_check -s exit:0 -o inline:'13:prefix\nsuffix\n' -e empty \ + ${TEST_SH} + + rm -f prefix* 2>/dev/null || : + oneline "echo hello >" 45 "" | + atf_check -s exit:0 -o empty -e empty ${TEST_SH} + test -f "prefix-suffix" || + atf_fail "failed to create prefix-suffix (45)" + test -s "prefix-suffix" || + atf_fail "no data in prefix-suffix (45)" + test "$(cat prefix-suffix)" = "hello" || + atf_fail "incorrect data in prefix-suffix (45)" + + return 0 +} + +atf_test_case assignment +assignment_head() { + atf_set "descr" "Check that all chars can be assigned to vars" +} +assignment_body() { + atf_require_prog grep + atf_require_prog rm + + rm -f results || : + mkdata "VAR=" -- '; echo ${#VAR}' | + atf_check -s exit:0 -o save:results -e empty ${TEST_SH} + test -z $( grep -v "^13$" results ) || + atf_fail "Incorrect lengths: $(grep -nv '^13$' results)" + + return 0 +} + +atf_test_case cmdline +cmdline_head() { + atf_set "descr" "Check vars containing all chars can be used" +} +cmdline_body() { + atf_require_prog rm + atf_require_prog wc + + rm -f results || : + mkdata "VAR=" -- '; echo "${VAR}"' | + atf_check -s exit:0 -o save:results -e empty ${TEST_SH} + + # 256 because one output line contains a \n ... + test $( wc -l < results ) -eq 256 || + atf_fail "incorrect line count in results" + test $(wc -c < results) -eq $(( 255 * 14 )) || + atf_fail "incorrect character count in results" + + return 0 +} + +atf_test_case redirect +redirect_head() { + atf_set "descr" "Check vars containing all chars can be used" +} +redirect_body() { + atf_require_prog ls + atf_require_prog wc + atf_require_prog rm + atf_require_prog mkdir + atf_require_prog rmdir + + nl=' +' + + rm -f prefix* suffix || : + + mkdir prefix # one of the files will be prefix/suffix + mkdata "VAR=" -- '; echo "${VAR}" > "${VAR}"' | + atf_check -s exit:0 -o empty -e empty ${TEST_SH} + + test -f "prefix/suffix" || + atf_fail "Failed to create file in subdirectory" + test $( wc -l < "prefix/suffix" ) -eq 1 || + atf_fail "Not exactly one line in prefix/suffix file" + + atf_check -s exit:0 -o empty -e empty rm "prefix/suffix" + atf_check -s exit:0 -o empty -e empty rmdir "prefix" + + test -f "prefix${nl}suffix" || + atf_fail "Failed to create file with newline in its name" + test $( wc -l < "prefix${nl}suffix" ) -eq 2 || + atf_fail "NewLine file did not contain embedded newline" + + atf_check -s exit:0 -o empty -e empty rm "prefix${nl}suffix" + + # Now there should be 253 files left... + test $( ls | wc -l ) -eq 253 || + atf_fail \ + "Did not create all expected files: wanted: 253, found ($( ls | wc -l ))" + + # and each of them should have a name that is 13 chars long (+ \n) + test $( ls | wc -c ) -eq $(( 253 * 14 )) || + atf_fail "File names do not appear to be as expected" + + return 0 +} + +atf_test_case read +read_head() { + atf_set "descr" "Check vars containing all chars can be used" +} +read_body() { + atf_require_prog ls + atf_require_prog wc + atf_require_prog rm + atf_require_prog mkdir + atf_require_prog rmdir + + nl=' +' + + rm -f prefix* suffix || : + + mkdir prefix # one of the files will be prefix/suffix + mkdata -q | + atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c ' + while read -r VAR + do + # skip the mess made by embedded newline + case "${VAR}" in + (prefix | suffix) continue;; + esac + echo "${VAR}" > "${VAR}" + done' + + test -f "prefix/suffix" || + atf_fail "Failed to create file in subdirectory" + test $( wc -l < "prefix/suffix" ) -eq 1 || + atf_fail "Not exactly one line in prefix/suffix file" + + atf_check -s exit:0 -o empty -e empty rm "prefix/suffix" + atf_check -s exit:0 -o empty -e empty rmdir "prefix" + + # Now there should be 253 files left... + test $( ls | wc -l ) -eq 253 || + atf_fail \ + "Did not create all expected files: wanted: 253, found ($( ls | wc -l ))" + + # and each of them should have a name that is 13 chars long (+ \n) + test $( ls | wc -c ) -eq $(( 253 * 14 )) || + atf_fail "File names do not appear to be as expected" + + return 0 +} + +atf_init_test_cases() { + atf_add_test_case aaa + atf_add_test_case assignment + atf_add_test_case cmdline + atf_add_test_case redirect + atf_add_test_case read +} diff --git a/contrib/netbsd-tests/bin/sh/t_wait.sh b/contrib/netbsd-tests/bin/sh/t_wait.sh index 99b47df..eaad7e0 100755 --- a/contrib/netbsd-tests/bin/sh/t_wait.sh +++ b/contrib/netbsd-tests/bin/sh/t_wait.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_wait.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# $NetBSD: t_wait.sh,v 1.8 2016/03/31 16:22:54 christos Exp $ # # Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc. # All rights reserved. @@ -24,36 +24,172 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # +# the implementation of "sh" to test +: ${TEST_SH:="/bin/sh"} + +atf_test_case basic_wait +basic_wait_head() { + atf_set "descr" "Tests simple uses of wait" +} +basic_wait_body() { + atf_require_prog sleep + + atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \ + '(echo nothing >/dev/null) & wait' + + atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \ + '(exit 3) & wait $!; S=$?; test $S -eq 3 || { + echo "status: $S"; exit 1; }' + + atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \ + 'sleep 3 & sleep 2 & sleep 1 & wait' + + atf_check -s exit:0 -o empty -e empty ${TEST_SH} -c \ + 'sleep 3 & (exit 2) & sleep 1 & wait' +} atf_test_case individual individual_head() { - atf_set "descr" "Tests that waiting for individual jobs works" + atf_set "descr" "Tests that waiting for individual processes works" } individual_body() { + atf_require_prog sleep + + cat >individualhelper.sh <<\EOF +sleep 3 & P1=$! +sleep 1 & P2=$! + +wait ${P1} +S=$? +if [ $S -ne 0 ]; then + echo "Waiting for first process failed: $S" + exit 1 +fi + +wait ${P2} +S=$? +if [ $? -ne 0 ]; then + echo "Waiting for second process failed" + exit 1 +fi + +exit 0 +EOF + output=$(${TEST_SH} individualhelper.sh 2>&1) + [ $? -eq 0 ] || atf_fail "${output}" +} + +atf_test_case jobs +jobs_head() { + atf_set "descr" "Tests that waiting for individual jobs works" +} +jobs_body() { # atf-sh confuses wait for some reason; work it around by creating # a helper script that executes /bin/sh directly. - cat >helper.sh </dev/null + then + atf_skip "No job control support in this shell" + fi + + cat >individualhelper.sh <<\EOF sleep 3 & sleep 1 & wait %1 -if [ \$? -ne 0 ]; then - echo "Waiting of first job failed" +if [ $? -ne 0 ]; then + echo "Waiting for first job failed" + exit 1 +fi + +wait %2 +if [ $? -ne 0 ]; then + echo "Waiting for second job failed" + exit 1 +fi + +exit 0 +EOF + output=$(${TEST_SH} individualhelper.sh 2>&1) + [ $? -eq 0 ] || atf_fail "${output}" + + cat >individualhelper.sh <<\EOF +{ sleep 3; exit 3; } & +{ sleep 1; exit 7; } & + +wait %1 +S=$? +if [ $S -ne 3 ]; then + echo "Waiting for first job failed - status: $S != 3 (expected)" exit 1 fi wait %2 -if [ \$? -ne 0 ]; then - echo "Waiting of second job failed" +S=$? +if [ $S -ne 7 ]; then + echo "Waiting for second job failed - status: $S != 7 (expected)" exit 1 fi exit 0 EOF - output=$(/bin/sh helper.sh) + + output=$(${TEST_SH} individualhelper.sh 2>&1) [ $? -eq 0 ] || atf_fail "${output}" } +atf_test_case kill +kill_head() { + atf_set "descr" "Tests that killing the shell while in wait calls trap" +} +kill_body() { + atf_require_prog sleep + atf_require_prog kill + + s=killhelper.sh + z=killhelper.$$ + pid= + + # waiting for a specific process that is not a child + # should return exit status of 127 according to the spec + # This test is here before the next, to avoid that one + # entering an infinite loop should the shell have a bug here. + + atf_check -s exit:127 -o empty -e ignore ${TEST_SH} -c 'wait 1' + + cat > "${s}" <<'EOF' + +trap "echo SIGHUP" 1 +(sleep 5; exit 3) & +sl=$! +wait +S=$? +echo $S +LS=9999 +while [ $S -ne 0 ] && [ $S != 127 ]; do + wait $sl; S=$?; echo $S + test $S = $LS && { echo "wait repeats..."; exit 2; } + LS=$S + done +EOF + + ${TEST_SH} $s > $z & + pid=$! + sleep 1 + + kill -HUP "${pid}" + wait + + output="$(cat $z | tr '\n' ' ')" + + if [ "$output" != "SIGHUP 129 3 127 " ]; then + atf_fail "${output} != 'SIGHUP 129 3 127 '" + fi +} + atf_init_test_cases() { + atf_add_test_case basic_wait atf_add_test_case individual + atf_add_test_case jobs + atf_add_test_case kill } diff --git a/contrib/netbsd-tests/crypto/opencrypto/t_opencrypto.sh b/contrib/netbsd-tests/crypto/opencrypto/t_opencrypto.sh index f7faa3a..e8e3f28 100755 --- a/contrib/netbsd-tests/crypto/opencrypto/t_opencrypto.sh +++ b/contrib/netbsd-tests/crypto/opencrypto/t_opencrypto.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_opencrypto.sh,v 1.4 2014/01/18 15:15:16 pgoyette Exp $ +# $NetBSD: t_opencrypto.sh,v 1.6 2015/12/26 07:10:03 pgoyette Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -80,7 +80,11 @@ arc4_body() { } arc4_cleanup() { - common_cleanup + # No cleanup required since test is skipped. Trying to run rump.halt + # at this point fails, causing the ATF environment to erroneously + # report a failed test! + # + # common_cleanup } atf_test_case camellia cleanup @@ -98,7 +102,7 @@ camellia_cleanup() { atf_test_case cbcdes cleanup cbcdes_head() { - common_head "Test ARC4 crypto" + common_head "Test DES_CBC crypto" } cbcdes_body() { diff --git a/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue b/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue index 0aadfa7..e0cbf52 100644 --- a/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue +++ b/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue @@ -1,998 +1,1035 @@ begin 644 t_pad_output.bz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-!6.LVSN`-N%'-?'3+QQK2]],QR(BCO16_A]R`("'A*6FG+GQMN[@ +M\N+3J.*ZC%Y,Y"!M8G7@`M=J\;M9&E_/&A[[/LWC,1#I;I9;G`XA`KVLS/:7 +M+WJ,2-3%!F+4@6`P:ETZ*-&ZL"]2-B0H+3K4H`!)+VO[BDGHZ$5RPUGIHQEF +MY504K%*A$.=J\C)R4-I,^B$_!X.4'MN#[V`3"I:[D)=O^_19RW;8%6E55&3E:\"H4GNR3=("`V%YKL?J_+H +M%+O\X_IU%@]B4!#6E![8_&@A+;Y)B=Y3_+D`+9HNUI(3Y)?WY8H@4)9\3#D?1 +ME0HX7U@GG=GN>YD"%P_W6DC^W0[CPOFE:5H[3-12VMKJFO[EK8`"G=AT[Z2SPX,E9?G4#KR&08@0H5]\U8GT'Q\>UV[ +M*"(9J/D)1WDZL;[+[[FL,#D]$[I8%A^,KX>O2+K``0VKJXS-/!G$U/#XG(0O +M"OJ_&SOB`$`QJDECIERVTTTSVI6G-&2C?GU8O)+ ./m1/text + +# configure and mount a snapshot of the file system + + fssconfig -c fss0 ./m1 ./backup + mount -o rdonly /dev/fss0 ./m2 + +# Modify the data on the underlying file system + + echo "${repl_data}" > ./m1/text || abort + +# Verify that original data is still visible in the snapshot + + read test_data < ./m2/text + atf_check_equal "${orig_data}" "${test_data}" + +# Unmount our temporary stuff + + umount /dev/fss0 || true + fssconfig -u fss0 || true + umount /dev/vnd0a || true + vndconfig -u vnd0 || true +} + +basic_cleanup() { + umount /dev/vnd0a || true + fssconfig -u fss0 || true + umount /dev/fss0 || true + vndconfig -u vnd0 || true +} + +atf_init_test_cases() +{ + atf_add_test_case basic +} diff --git a/contrib/netbsd-tests/dev/sysmon/t_swsensor.sh b/contrib/netbsd-tests/dev/sysmon/t_swsensor.sh index 5b54431..7f98c1a 100755 --- a/contrib/netbsd-tests/dev/sysmon/t_swsensor.sh +++ b/contrib/netbsd-tests/dev/sysmon/t_swsensor.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_swsensor.sh,v 1.7 2013/04/14 16:07:46 martin Exp $ +# $NetBSD: t_swsensor.sh,v 1.9 2015/04/23 23:23:28 pgoyette Exp $ get_sensor_info() { rump.envstat -x | \ @@ -6,7 +6,13 @@ get_sensor_info() { } get_sensor_key() { - get_sensor_info | grep -A1 $1 | grep integer | sed -e 's;<[/a-z]*>;;g' + local v + v=$(get_sensor_info | grep -A1 $1 | grep integer | \ + sed -e 's;<[/a-z]*>;;g') + if [ -z "$v" ] ; then + v="key_$1_not_found" + fi + echo $v } get_powerd_event_count() { @@ -60,7 +66,7 @@ start_rump() { common_head() { atf_set descr "$1" - atf_set timeout 60 + atf_set timeout 120 atf_set require.progs rump.powerd rump.envstat rump.modload \ rump.halt rump.sysctl rump_server \ sed grep awk \ diff --git a/contrib/netbsd-tests/dev/sysmon/t_swwdog.c b/contrib/netbsd-tests/dev/sysmon/t_swwdog.c index 19e3795..1635884 100644 --- a/contrib/netbsd-tests/dev/sysmon/t_swwdog.c +++ b/contrib/netbsd-tests/dev/sysmon/t_swwdog.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_swwdog.c,v 1.5 2011/06/26 12:14:59 christos Exp $ */ +/* $NetBSD: t_swwdog.c,v 1.6 2015/04/23 04:49:37 pgoyette Exp $ */ /* * Copyright (c) 2010 Antti Kantee. All Rights Reserved. @@ -121,6 +121,7 @@ testbody(int max) _exit(2); } /* fail */ + printf("no watchdog registered!\n"); _exit(1); } diff --git a/contrib/netbsd-tests/dev/usb/t_hid.c b/contrib/netbsd-tests/dev/usb/t_hid.c new file mode 100644 index 0000000..31c289b --- /dev/null +++ b/contrib/netbsd-tests/dev/usb/t_hid.c @@ -0,0 +1,267 @@ +/* $NetBSD: t_hid.c,v 1.8 2016/05/05 17:40:26 jakllsch Exp $ */ + +/* + * Copyright (c) 2016 Jonathan A. Kollasch + * 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ + +#include +__RCSID("$NetBSD: t_hid.c,v 1.8 2016/05/05 17:40:26 jakllsch Exp $"); + +#include +#include +#include +#include +#include + +#include + +#define hid_start_parse rumpns_hid_start_parse +#define hid_end_parse rumpns_hid_end_parse +#define hid_get_item rumpns_hid_get_item +#define hid_locate rumpns_hid_locate +#define hid_report_size rumpns_hid_report_size +#define hid_get_data rumpns_hid_get_data +#define hid_get_udata rumpns_hid_get_udata +#define uhidevdebug rumpns_uhidevdebug +#include +#include +#include + +#include "../../lib/libusbhid/hid_test_data.c" + +#define MYd_ATF_CHECK_EQ(d, v) \ + ATF_CHECK_EQ_MSG(d, v, "== %d", (d)) + +#define MYld_ATF_CHECK_EQ(d, v) \ + ATF_CHECK_EQ_MSG(d, v, "== %ld", (d)) + +#define MYu_ATF_CHECK_EQ(d, v) \ + ATF_CHECK_EQ_MSG(d, v, "== %u", (d)) + +#define MYlu_ATF_CHECK_EQ(d, v) \ + ATF_CHECK_EQ_MSG(d, v, "== %lu", (d)) + +#define MYx_ATF_CHECK_EQ(d, v) \ + ATF_CHECK_EQ_MSG(d, v, "== 0x%x", (d)) + +#define MYlx_ATF_CHECK_EQ(d, v) \ + ATF_CHECK_EQ_MSG(d, v, "== 0x%lx", (d)) + +int uhidevdebug; + +ATF_TC(khid); + +ATF_TC_HEAD(khid, tc) +{ + + atf_tc_set_md_var(tc, "descr", "check kernel hid.c"); +} + +static int +locate_item(const void *desc, int size, u_int32_t u, u_int8_t id, + enum hid_kind k, struct hid_item *hip) +{ + struct hid_data *d; + struct hid_item h; + + h.report_ID = 0; + for (d = hid_start_parse(desc, size, k); hid_get_item(d, &h); ) { + if (h.kind == k && !(h.flags & HIO_CONST) && + (/*XXX*/uint32_t)h.usage == u && h.report_ID == id) { + if (hip != NULL) + *hip = h; + hid_end_parse(d); + return (1); + } + } + hid_end_parse(d); + return (0); +} + +ATF_TC_BODY(khid, tc) +{ + int ret; + struct hid_item hi; + + uhidevdebug = 0; + + rump_init(); + + rump_schedule(); + + ret = locate_item(range_test_report_descriptor, + sizeof(range_test_report_descriptor), 0xff000003, 0, hid_input, + &hi); + ATF_REQUIRE(ret > 0); + MYu_ATF_CHECK_EQ(hi.loc.size, 32); + MYu_ATF_CHECK_EQ(hi.loc.count, 1); + MYu_ATF_CHECK_EQ(hi.loc.pos, 0); + MYx_ATF_CHECK_EQ(hi.flags, 0); + MYd_ATF_CHECK_EQ(hi.logical_minimum, -2147483648); + MYd_ATF_CHECK_EQ(hi.logical_maximum, 2147483647); + MYd_ATF_CHECK_EQ(hi.physical_minimum, -2147483648); + MYd_ATF_CHECK_EQ(hi.physical_maximum, 2147483647); + MYld_ATF_CHECK_EQ(hid_get_data(range_test_minimum_report, + &hi.loc), -2147483648); + MYld_ATF_CHECK_EQ(hid_get_data(range_test_negative_one_report, + &hi.loc), -1); + MYld_ATF_CHECK_EQ(hid_get_data(range_test_positive_one_report, + &hi.loc), 1); + MYld_ATF_CHECK_EQ(hid_get_data(range_test_maximum_report, + &hi.loc), 2147483647); + + ret = locate_item(range_test_report_descriptor, + sizeof(range_test_report_descriptor), 0xff000002, 0, hid_input, + &hi); + ATF_REQUIRE(ret > 0); + MYu_ATF_CHECK_EQ(hi.loc.size, 16); + MYu_ATF_CHECK_EQ(hi.loc.count, 1); + MYu_ATF_CHECK_EQ(hi.loc.pos, 32); + MYx_ATF_CHECK_EQ(hi.flags, 0); + MYd_ATF_CHECK_EQ(hi.logical_minimum, -32768); + MYd_ATF_CHECK_EQ(hi.logical_maximum, 32767); + MYd_ATF_CHECK_EQ(hi.physical_minimum, -32768); + MYd_ATF_CHECK_EQ(hi.physical_maximum, 32767); + MYld_ATF_CHECK_EQ(hid_get_data(range_test_minimum_report, + &hi.loc), -32768); + MYld_ATF_CHECK_EQ(hid_get_data(range_test_negative_one_report, + &hi.loc), -1); + MYld_ATF_CHECK_EQ(hid_get_data(range_test_positive_one_report, + &hi.loc), 1); + MYld_ATF_CHECK_EQ(hid_get_data(range_test_maximum_report, + &hi.loc), 32767); + + ret = locate_item(range_test_report_descriptor, + sizeof(range_test_report_descriptor), 0xff000001, 0, hid_input, + &hi); + ATF_REQUIRE(ret > 0); + MYu_ATF_CHECK_EQ(hi.loc.size, 8); + MYu_ATF_CHECK_EQ(hi.loc.count, 1); + MYu_ATF_CHECK_EQ(hi.loc.pos, 48); + MYx_ATF_CHECK_EQ(hi.flags, 0); + MYd_ATF_CHECK_EQ(hi.logical_minimum, -128); + MYd_ATF_CHECK_EQ(hi.logical_maximum, 127); + MYd_ATF_CHECK_EQ(hi.physical_minimum, -128); + MYd_ATF_CHECK_EQ(hi.physical_maximum, 127); + MYld_ATF_CHECK_EQ(hid_get_data(range_test_minimum_report, + &hi.loc), -128); + MYld_ATF_CHECK_EQ(hid_get_data(range_test_negative_one_report, + &hi.loc), -1); + MYld_ATF_CHECK_EQ(hid_get_data(range_test_positive_one_report, + &hi.loc), 1); + MYld_ATF_CHECK_EQ(hid_get_data(range_test_maximum_report, + &hi.loc), 127); + + + ret = locate_item(unsigned_range_test_report_descriptor, + sizeof(unsigned_range_test_report_descriptor), 0xff000013, 0, + hid_input, &hi); + ATF_REQUIRE(ret > 0); + MYu_ATF_CHECK_EQ(hi.loc.size, 32); + MYu_ATF_CHECK_EQ(hi.loc.count, 1); + MYu_ATF_CHECK_EQ(hi.loc.pos, 0); + MYx_ATF_CHECK_EQ(hi.flags, 0); + MYlx_ATF_CHECK_EQ(hid_get_udata(unsigned_range_test_minimum_report, + &hi.loc), 0x0); + MYlx_ATF_CHECK_EQ(hid_get_udata(unsigned_range_test_positive_one_report, + &hi.loc), 0x1); + MYlx_ATF_CHECK_EQ(hid_get_udata(unsigned_range_test_negative_one_report, + &hi.loc), 0xfffffffe); + MYlx_ATF_CHECK_EQ(hid_get_udata(unsigned_range_test_maximum_report, + &hi.loc), 0xffffffff); + + ret = locate_item(unsigned_range_test_report_descriptor, + sizeof(unsigned_range_test_report_descriptor), 0xff000012, 0, + hid_input, &hi); + ATF_REQUIRE(ret > 0); + MYu_ATF_CHECK_EQ(hi.loc.size, 16); + MYu_ATF_CHECK_EQ(hi.loc.count, 1); + MYu_ATF_CHECK_EQ(hi.loc.pos, 32); + MYx_ATF_CHECK_EQ(hi.flags, 0); + MYlx_ATF_CHECK_EQ(hid_get_udata(unsigned_range_test_minimum_report, + &hi.loc), 0x0); + MYlx_ATF_CHECK_EQ(hid_get_udata(unsigned_range_test_positive_one_report, + &hi.loc), 0x1); + MYlx_ATF_CHECK_EQ(hid_get_udata(unsigned_range_test_negative_one_report, + &hi.loc), 0xfffe); + MYlx_ATF_CHECK_EQ(hid_get_udata(unsigned_range_test_maximum_report, + &hi.loc), 0xffff); + + ret = locate_item(unsigned_range_test_report_descriptor, + sizeof(unsigned_range_test_report_descriptor), 0xff000011, 0, + hid_input, &hi); + ATF_REQUIRE(ret > 0); + MYu_ATF_CHECK_EQ(hi.loc.size, 8); + MYu_ATF_CHECK_EQ(hi.loc.count, 1); + MYu_ATF_CHECK_EQ(hi.loc.pos, 48); + MYx_ATF_CHECK_EQ(hi.flags, 0); + MYlx_ATF_CHECK_EQ(hid_get_udata(unsigned_range_test_minimum_report, + &hi.loc), 0x0); + MYlx_ATF_CHECK_EQ(hid_get_udata(unsigned_range_test_positive_one_report, + &hi.loc), 0x1); + MYlx_ATF_CHECK_EQ(hid_get_udata(unsigned_range_test_negative_one_report, + &hi.loc), 0xfe); + MYlx_ATF_CHECK_EQ(hid_get_udata(unsigned_range_test_maximum_report, + &hi.loc), 0xff); + + rump_unschedule(); +} + +ATF_TC(khid_parse_just_pop); + +ATF_TC_HEAD(khid_parse_just_pop, tc) +{ + + atf_tc_set_md_var(tc, "descr", "check kernel hid.c for " + "Pop on empty stack bug"); +} + +ATF_TC_BODY(khid_parse_just_pop, tc) +{ + struct hid_data *hdp; + struct hid_item hi; + + rump_init(); + + rump_schedule(); + + hdp = hid_start_parse(just_pop_report_descriptor, + sizeof just_pop_report_descriptor, hid_none); + while (hid_get_item(hdp, &hi) > 0) { + } + hid_end_parse(hdp); + + rump_unschedule(); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, khid); + ATF_TP_ADD_TC(tp, khid_parse_just_pop); + + return atf_no_error(); +} + diff --git a/contrib/netbsd-tests/fs/common/fstest_lfs.c b/contrib/netbsd-tests/fs/common/fstest_lfs.c index fd131cf..597ca23 100644 --- a/contrib/netbsd-tests/fs/common/fstest_lfs.c +++ b/contrib/netbsd-tests/fs/common/fstest_lfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: fstest_lfs.c,v 1.4 2010/07/30 16:15:05 pooka Exp $ */ +/* $NetBSD: fstest_lfs.c,v 1.5 2015/08/30 18:27:26 dholland Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -48,8 +48,6 @@ #include "h_fsmacros.h" #include "mount_lfs.h" -sem_t lfs_clearnerloop; - struct lfstestargs { struct ufs_args ta_uargs; pthread_t ta_cleanerthread; diff --git a/contrib/netbsd-tests/fs/common/h_fsmacros.h b/contrib/netbsd-tests/fs/common/h_fsmacros.h index b47a708..b295cf2 100644 --- a/contrib/netbsd-tests/fs/common/h_fsmacros.h +++ b/contrib/netbsd-tests/fs/common/h_fsmacros.h @@ -1,4 +1,4 @@ -/* $NetBSD: h_fsmacros.h,v 1.38 2013/06/26 19:29:24 reinoud Exp $ */ +/* $NetBSD: h_fsmacros.h,v 1.40 2015/08/29 19:19:43 dholland Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -110,10 +110,6 @@ do { \ atf_tc_set_md_var(tc, "descr", type " test for " desc); \ atf_tc_set_md_var(tc, "X-fs.type", #fs); \ atf_tc_set_md_var(tc, "X-fs.mntname", type); \ - if (strcmp(#fs, "zfs") == 0) { \ - /* This should not be necessary. */ \ - atf_tc_set_md_var(tc, "require.user", "root"); \ - } \ } \ void *fs##func##tmp; \ \ @@ -136,10 +132,6 @@ do { \ atf_tc_set_md_var(tc, "descr",_type_" test for "_desc_);\ atf_tc_set_md_var(tc, "X-fs.type", #_fs_); \ atf_tc_set_md_var(tc, "X-fs.mntname", _type_); \ - if (strcmp(#_fs_, "zfs") == 0) { \ - /* This should not be necessary. */ \ - atf_tc_set_md_var(tc, "require.user", "root"); \ - } \ } \ void *_fs_##_func_##tmp; \ \ @@ -153,7 +145,7 @@ do { \ atf_tc_fail_errno("unmount r/w failed"); \ if (_fs_##_fstest_mount(tc, _fs_##_func_##tmp, \ FSTEST_MNTNAME, MNT_RDONLY) != 0) \ - atf_tc_fail_errno("mount ro failed"); \ + atf_tc_fail_errno("mount ro failed"); \ _func_(tc,FSTEST_MNTNAME); \ if (_fs_##_fstest_unmount(tc, FSTEST_MNTNAME, 0) != 0) {\ rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); \ diff --git a/contrib/netbsd-tests/fs/nfs/nfsservice/mountd.c b/contrib/netbsd-tests/fs/nfs/nfsservice/mountd.c deleted file mode 100644 index b3625f6..0000000 --- a/contrib/netbsd-tests/fs/nfs/nfsservice/mountd.c +++ /dev/null @@ -1,2575 +0,0 @@ -/* $NetBSD: mountd.c,v 1.8 2013/10/19 17:45:00 christos Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Herb Hasler and Rick Macklem at The University of Guelph. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include -#ifndef lint -__COPYRIGHT("@(#) Copyright (c) 1989, 1993\ - The Regents of the University of California. All rights reserved."); -#endif /* not lint */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95"; -#else -__RCSID("$NetBSD: mountd.c,v 1.8 2013/10/19 17:45:00 christos Exp $"); -#endif -#endif /* not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "pathnames.h" - -#ifdef IPSEC -#include -#ifndef IPSEC_POLICY_IPSEC /* no ipsec support on old ipsec */ -#undef IPSEC -#endif -#include "ipsec.h" -#endif - -#include "svc_fdset.h" - -#include - -/* - * Structures for keeping the mount list and export list - */ -struct mountlist { - struct mountlist *ml_next; - char ml_host[RPCMNT_NAMELEN + 1]; - char ml_dirp[RPCMNT_PATHLEN + 1]; - int ml_flag;/* XXX more flags (same as dp_flag) */ -}; - -struct dirlist { - struct dirlist *dp_left; - struct dirlist *dp_right; - int dp_flag; - struct hostlist *dp_hosts; /* List of hosts this dir exported to */ - char dp_dirp[1]; /* Actually malloc'd to size of dir */ -}; -/* dp_flag bits */ -#define DP_DEFSET 0x1 -#define DP_HOSTSET 0x2 -#define DP_KERB 0x4 -#define DP_NORESMNT 0x8 - -struct exportlist { - struct exportlist *ex_next; - struct dirlist *ex_dirl; - struct dirlist *ex_defdir; - int ex_flag; - fsid_t ex_fs; - char *ex_fsdir; - char *ex_indexfile; -}; -/* ex_flag bits */ -#define EX_LINKED 0x1 - -struct netmsk { - struct sockaddr_storage nt_net; - int nt_len; - char *nt_name; -}; - -union grouptypes { - struct addrinfo *gt_addrinfo; - struct netmsk gt_net; -}; - -struct grouplist { - int gr_type; - union grouptypes gr_ptr; - struct grouplist *gr_next; -}; -/* Group types */ -#define GT_NULL 0x0 -#define GT_HOST 0x1 -#define GT_NET 0x2 - -struct hostlist { - int ht_flag;/* Uses DP_xx bits */ - struct grouplist *ht_grp; - struct hostlist *ht_next; -}; - -struct fhreturn { - int fhr_flag; - int fhr_vers; - size_t fhr_fhsize; - union { - uint8_t v2[NFSX_V2FH]; - uint8_t v3[NFSX_V3FHMAX]; - } fhr_fh; -}; - -/* Global defs */ -static char *add_expdir __P((struct dirlist **, char *, int)); -static void add_dlist __P((struct dirlist **, struct dirlist *, - struct grouplist *, int)); -static void add_mlist __P((char *, char *, int)); -static int check_dirpath __P((const char *, size_t, char *)); -static int check_options __P((const char *, size_t, struct dirlist *)); -static int chk_host __P((struct dirlist *, struct sockaddr *, int *, int *)); -static int del_mlist __P((char *, char *, struct sockaddr *)); -static struct dirlist *dirp_search __P((struct dirlist *, char *)); -static int do_nfssvc __P((const char *, size_t, struct exportlist *, - struct grouplist *, int, struct uucred *, char *, int, struct statvfs *)); -static int do_opt __P((const char *, size_t, char **, char **, - struct exportlist *, struct grouplist *, int *, int *, struct uucred *)); -static struct exportlist *ex_search __P((fsid_t *)); -static int parse_directory __P((const char *, size_t, struct grouplist *, - int, char *, struct exportlist **, struct statvfs *)); -static int parse_host_netgroup __P((const char *, size_t, struct exportlist *, - struct grouplist *, char *, int *, struct grouplist **)); -static struct exportlist *get_exp __P((void)); -static void free_dir __P((struct dirlist *)); -static void free_exp __P((struct exportlist *)); -static void free_grp __P((struct grouplist *)); -static void free_host __P((struct hostlist *)); -void get_exportlist __P((int)); -static int get_host __P((const char *, size_t, const char *, - struct grouplist *)); -static struct hostlist *get_ht __P((void)); -static void get_mountlist __P((void)); -static int get_net __P((char *, struct netmsk *, int)); -static void free_exp_grp __P((struct exportlist *, struct grouplist *)); -static struct grouplist *get_grp __P((void)); -static void hang_dirp __P((struct dirlist *, struct grouplist *, - struct exportlist *, int)); -static void mntsrv __P((struct svc_req *, SVCXPRT *)); -static void nextfield __P((char **, char **)); -static void parsecred __P((char *, struct uucred *)); -static int put_exlist __P((struct dirlist *, XDR *, struct dirlist *, int *)); -static int scan_tree __P((struct dirlist *, struct sockaddr *)); -static void send_umntall __P((int)); -#if 0 -static int umntall_each __P((caddr_t, struct sockaddr_in *)); -#endif -static int xdr_dir __P((XDR *, char *)); -static int xdr_explist __P((XDR *, caddr_t)); -static int xdr_fhs __P((XDR *, caddr_t)); -static int xdr_mlist __P((XDR *, caddr_t)); -static int bitcmp __P((void *, void *, int)); -static int netpartcmp __P((struct sockaddr *, struct sockaddr *, int)); -static int sacmp __P((struct sockaddr *, struct sockaddr *)); -static int allones __P((struct sockaddr_storage *, int)); -static int countones __P((struct sockaddr *)); -static void bind_resv_port __P((int, sa_family_t, in_port_t)); -static void no_nfs(int); -static struct exportlist *exphead; -static struct mountlist *mlhead; -static struct grouplist *grphead; -static char *exname; -static struct uucred def_anon = { - 1, - (uid_t) -2, - (gid_t) -2, - 0, - { 0 } -}; - -static int opt_flags; -static int have_v6 = 1; -static const int ninumeric = NI_NUMERICHOST; - -/* Bits for above */ -#define OP_MAPROOT 0x001 -#define OP_MAPALL 0x002 -#define OP_KERB 0x004 -#define OP_MASK 0x008 -#define OP_NET 0x010 -#define OP_ALLDIRS 0x040 -#define OP_NORESPORT 0x080 -#define OP_NORESMNT 0x100 -#define OP_MASKLEN 0x200 - -static int debug = 1; -#if 0 -static void SYSLOG __P((int, const char *,...)); -#endif -int main __P((int, char *[])); - -/* - * If this is non-zero, -noresvport and -noresvmnt are implied for - * each export. - */ -static int noprivports; - -#define C2FD(_c_) ((int)(uintptr_t)(_c_)) -static int -rumpread(void *cookie, char *buf, int count) -{ - - return rump_sys_read(C2FD(cookie), buf, count); -} - -static int -rumpwrite(void *cookie, const char *buf, int count) -{ - - return rump_sys_write(C2FD(cookie), buf, count); -} - -static off_t -rumpseek(void *cookie, off_t off, int whence) -{ - - return rump_sys_lseek(C2FD(cookie), off, whence); -} - -static int -rumpclose(void *cookie) -{ - - return rump_sys_close(C2FD(cookie)); -} - -int __sflags(const char *, int *); /* XXX */ -static FILE * -rumpfopen(const char *path, const char *opts) -{ - int fd, oflags; - - __sflags(opts, &oflags); - fd = rump_sys_open(path, oflags, 0777); - if (fd == -1) - return NULL; - - return funopen((void *)(uintptr_t)fd, - rumpread, rumpwrite, rumpseek, rumpclose); -} - -/* - * Make sure mountd signal handler is executed from a thread context - * instead of the signal handler. This avoids the signal handler - * ruining our kernel context. - */ -static sem_t exportsem; -static void -signal_get_exportlist(int sig) -{ - - sem_post(&exportsem); -} - -static void * -exportlist_thread(void *arg) -{ - - for (;;) { - sem_wait(&exportsem); - get_exportlist(0); - } - - return NULL; -} - -/* - * Mountd server for NFS mount protocol as described in: - * NFS: Network File System Protocol Specification, RFC1094, Appendix A - * The optional arguments are the exports file name - * default: _PATH_EXPORTS - * "-d" to enable debugging - * and "-n" to allow nonroot mount. - */ -void *mountd_main(void *); -void * -mountd_main(void *arg) -{ - SVCXPRT *udptransp, *tcptransp; - struct netconfig *udpconf, *tcpconf; - int udpsock, tcpsock; - int xcreated = 0; - int maxrec = RPC_MAXDATASIZE; - in_port_t forcedport = 0; - extern sem_t gensem; - pthread_t ptdummy; - - alloc_fdset(); - -#if 0 - while ((c = getopt(argc, argv, "dNnrp:" ADDOPTS)) != -1) - switch (c) { -#ifdef IPSEC - case 'P': - if (ipsecsetup_test(policy = optarg)) - errx(1, "Invalid ipsec policy `%s'", policy); - break; -#endif - case 'p': - /* A forced port "0" will dynamically allocate a port */ - forcedport = atoi(optarg); - break; - case 'd': - debug = 1; - break; - case 'N': - noprivports = 1; - break; - /* Compatibility */ - case 'n': - case 'r': - break; - default: - fprintf(stderr, "usage: %s [-dNn]" -#ifdef IPSEC - " [-P policy]" -#endif - " [-p port] [exportsfile]\n", getprogname()); - exit(1); - }; - argc -= optind; - argv += optind; -#endif - - sem_init(&exportsem, 0, 0); - pthread_create(&ptdummy, NULL, exportlist_thread, NULL); - - grphead = NULL; - exphead = NULL; - mlhead = NULL; - exname = _PATH_EXPORTS; - openlog("mountd", LOG_PID | (debug ? LOG_PERROR : 0), LOG_DAEMON); - (void)signal(SIGSYS, no_nfs); - - if (debug) - (void)fprintf(stderr, "Getting export list.\n"); - get_exportlist(0); - if (debug) - (void)fprintf(stderr, "Getting mount list.\n"); - get_mountlist(); - if (debug) - (void)fprintf(stderr, "Here we go.\n"); - if (debug == 0) { - daemon(0, 0); - (void)signal(SIGINT, SIG_IGN); - (void)signal(SIGQUIT, SIG_IGN); - } - (void)signal(SIGHUP, signal_get_exportlist); - (void)signal(SIGTERM, send_umntall); - pidfile(NULL); - - rpcb_unset(RPCPROG_MNT, RPCMNT_VER1, NULL); - rpcb_unset(RPCPROG_MNT, RPCMNT_VER3, NULL); - - udpsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - tcpsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - - udpconf = getnetconfigent("udp"); - tcpconf = getnetconfigent("tcp"); - - rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec); - - if (udpsock != -1 && udpconf != NULL) { - bind_resv_port(udpsock, AF_INET, forcedport); -#ifdef IPSEC - if (policy) - ipsecsetup(AF_INET, udpsock, policy); -#endif - udptransp = svc_dg_create(udpsock, 0, 0); - if (udptransp != NULL) { - if (!svc_reg(udptransp, RPCPROG_MNT, RPCMNT_VER1, - mntsrv, udpconf) || - !svc_reg(udptransp, RPCPROG_MNT, RPCMNT_VER3, - mntsrv, udpconf)) { - syslog(LOG_WARNING, "can't register UDP service"); - } - else { - xcreated++; - } - } else { - syslog(LOG_WARNING, "can't create UDP service"); - } - - } - - if (tcpsock != -1 && tcpconf != NULL) { - bind_resv_port(tcpsock, AF_INET, forcedport); -#ifdef IPSEC - if (policy) - ipsecsetup(AF_INET, tcpsock, policy); -#endif - listen(tcpsock, SOMAXCONN); - tcptransp = svc_vc_create(tcpsock, RPC_MAXDATASIZE, - RPC_MAXDATASIZE); - if (tcptransp != NULL) { - if (!svc_reg(tcptransp, RPCPROG_MNT, RPCMNT_VER1, - mntsrv, tcpconf) || - !svc_reg(tcptransp, RPCPROG_MNT, RPCMNT_VER3, - mntsrv, tcpconf)) - syslog(LOG_WARNING, "can't register TCP service"); - else - xcreated++; - } else - syslog(LOG_WARNING, "can't create TCP service"); - - } - - if (xcreated == 0) { - syslog(LOG_ERR, "could not create any services"); - exit(1); - } - - sem_post(&gensem); - svc_run(); - syslog(LOG_ERR, "Mountd died"); - exit(1); -} - -/* - * The mount rpc service - */ -void -mntsrv(rqstp, transp) - struct svc_req *rqstp; - SVCXPRT *transp; -{ - struct exportlist *ep; - struct dirlist *dp; - struct fhreturn fhr; - struct stat stb; - struct statvfs fsb; - char host[NI_MAXHOST], numerichost[NI_MAXHOST]; - int lookup_failed = 1; - struct sockaddr *saddr; - u_short sport; - char rpcpath[RPCMNT_PATHLEN + 1], dpath[MAXPATHLEN]; - long bad = EACCES; - int defset, hostset, ret; - sigset_t sighup_mask; - struct sockaddr_in6 *sin6; - struct sockaddr_in *sin; - size_t fh_size; - int error = 0; - - (void)sigemptyset(&sighup_mask); - (void)sigaddset(&sighup_mask, SIGHUP); - saddr = svc_getrpccaller(transp)->buf; - switch (saddr->sa_family) { - case AF_INET6: - sin6 = (struct sockaddr_in6 *)saddr; - sport = ntohs(sin6->sin6_port); - break; - case AF_INET: - sin = (struct sockaddr_in *)saddr; - sport = ntohs(sin->sin_port); - break; - default: - syslog(LOG_ERR, "request from unknown address family"); - return; - } - lookup_failed = getnameinfo(saddr, saddr->sa_len, host, sizeof host, - NULL, 0, 0); - if (getnameinfo(saddr, saddr->sa_len, numerichost, - sizeof numerichost, NULL, 0, ninumeric) != 0) - strlcpy(numerichost, "?", sizeof(numerichost)); - ret = 0; - switch (rqstp->rq_proc) { - case NULLPROC: - if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) - syslog(LOG_ERR, "Can't send reply"); - return; - case MOUNTPROC_MNT: - if (debug) - fprintf(stderr, - "got mount request from %s\n", numerichost); - if (!svc_getargs(transp, xdr_dir, rpcpath)) { - if (debug) - fprintf(stderr, "-> garbage args\n"); - svcerr_decode(transp); - return; - } - if (debug) - fprintf(stderr, - "-> rpcpath: %s\n", rpcpath); - /* - * Get the real pathname and make sure it is a file or - * directory that exists. - */ -#if 0 - if (realpath(rpcpath, dpath) == 0 || -#endif - strcpy(dpath, rpcpath); - if (rump_sys_stat(dpath, &stb) < 0 || - (!S_ISDIR(stb.st_mode) && !S_ISREG(stb.st_mode)) || - rump_sys_statvfs1(dpath, &fsb, ST_WAIT) < 0) { - (void)chdir("/"); /* Just in case realpath doesn't */ - if (debug) - (void)fprintf(stderr, "-> stat failed on %s\n", - dpath); - if (!svc_sendreply(transp, (xdrproc_t)xdr_long, (caddr_t) &bad)) - syslog(LOG_ERR, "Can't send reply"); - return; - } - if (debug) - fprintf(stderr, - "-> dpath: %s\n", dpath); - /* Check in the exports list */ - (void)sigprocmask(SIG_BLOCK, &sighup_mask, NULL); - ep = ex_search(&fsb.f_fsidx); - hostset = defset = 0; - if (ep && (chk_host(ep->ex_defdir, saddr, &defset, - &hostset) || ((dp = dirp_search(ep->ex_dirl, dpath)) && - chk_host(dp, saddr, &defset, &hostset)) || - (defset && scan_tree(ep->ex_defdir, saddr) == 0 && - scan_tree(ep->ex_dirl, saddr) == 0))) { - if ((hostset & DP_HOSTSET) == 0) { - hostset = defset; - } - if (sport >= IPPORT_RESERVED && - !(hostset & DP_NORESMNT)) { - syslog(LOG_NOTICE, - "Refused mount RPC from host %s port %d", - numerichost, sport); - svcerr_weakauth(transp); - goto out; - } - fhr.fhr_flag = hostset; - fhr.fhr_vers = rqstp->rq_vers; - /* Get the file handle */ - memset(&fhr.fhr_fh, 0, sizeof(fhr.fhr_fh)); /* for v2 */ - fh_size = sizeof(fhr.fhr_fh); - error = 0; - if (rump_sys_getfh(dpath, &fhr.fhr_fh, &fh_size) < 0) { - bad = error; - //syslog(LOG_ERR, "Can't get fh for %s %d %d", dpath, error, fh_size); - if (!svc_sendreply(transp, (xdrproc_t)xdr_long, - (char *)&bad)) - syslog(LOG_ERR, "Can't send reply"); - goto out; - } - if ((fhr.fhr_vers == 1 && fh_size > NFSX_V2FH) || - fh_size > NFSX_V3FHMAX) { - bad = EINVAL; /* XXX */ - if (!svc_sendreply(transp, (xdrproc_t)xdr_long, - (char *)&bad)) - syslog(LOG_ERR, "Can't send reply"); - goto out; - } - fhr.fhr_fhsize = fh_size; - if (!svc_sendreply(transp, (xdrproc_t)xdr_fhs, (char *) &fhr)) - syslog(LOG_ERR, "Can't send reply"); - if (!lookup_failed) - add_mlist(host, dpath, hostset); - else - add_mlist(numerichost, dpath, hostset); - if (debug) - (void)fprintf(stderr, "Mount successful.\n"); - } else { - if (!svc_sendreply(transp, (xdrproc_t)xdr_long, (caddr_t) &bad)) - syslog(LOG_ERR, "Can't send reply"); - } -out: - (void)sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); - return; - case MOUNTPROC_DUMP: - if (!svc_sendreply(transp, (xdrproc_t)xdr_mlist, NULL)) - syslog(LOG_ERR, "Can't send reply"); - return; - case MOUNTPROC_UMNT: - if (!svc_getargs(transp, xdr_dir, dpath)) { - svcerr_decode(transp); - return; - } - if (!lookup_failed) - ret = del_mlist(host, dpath, saddr); - ret |= del_mlist(numerichost, dpath, saddr); - if (ret) { - svcerr_weakauth(transp); - return; - } - if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) - syslog(LOG_ERR, "Can't send reply"); - return; - case MOUNTPROC_UMNTALL: - if (!lookup_failed) - ret = del_mlist(host, NULL, saddr); - ret |= del_mlist(numerichost, NULL, saddr); - if (ret) { - svcerr_weakauth(transp); - return; - } - if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) - syslog(LOG_ERR, "Can't send reply"); - return; - case MOUNTPROC_EXPORT: - case MOUNTPROC_EXPORTALL: - if (!svc_sendreply(transp, (xdrproc_t)xdr_explist, NULL)) - syslog(LOG_ERR, "Can't send reply"); - return; - - - default: - svcerr_noproc(transp); - return; - } -} - -/* - * Xdr conversion for a dpath string - */ -static int -xdr_dir(xdrsp, dirp) - XDR *xdrsp; - char *dirp; -{ - - return (xdr_string(xdrsp, &dirp, RPCMNT_PATHLEN)); -} - -/* - * Xdr routine to generate file handle reply - */ -static int -xdr_fhs(xdrsp, cp) - XDR *xdrsp; - caddr_t cp; -{ - struct fhreturn *fhrp = (struct fhreturn *) cp; - long ok = 0, len, auth; - - if (!xdr_long(xdrsp, &ok)) - return (0); - switch (fhrp->fhr_vers) { - case 1: - return (xdr_opaque(xdrsp, (caddr_t)&fhrp->fhr_fh, NFSX_V2FH)); - case 3: - len = fhrp->fhr_fhsize; - if (!xdr_long(xdrsp, &len)) - return (0); - if (!xdr_opaque(xdrsp, (caddr_t)&fhrp->fhr_fh, len)) - return (0); - if (fhrp->fhr_flag & DP_KERB) - auth = RPCAUTH_KERB4; - else - auth = RPCAUTH_UNIX; - len = 1; - if (!xdr_long(xdrsp, &len)) - return (0); - return (xdr_long(xdrsp, &auth)); - }; - return (0); -} - -int -xdr_mlist(xdrsp, cp) - XDR *xdrsp; - caddr_t cp; -{ - struct mountlist *mlp; - int trueval = 1; - int falseval = 0; - char *strp; - - mlp = mlhead; - while (mlp) { - if (!xdr_bool(xdrsp, &trueval)) - return (0); - strp = &mlp->ml_host[0]; - if (!xdr_string(xdrsp, &strp, RPCMNT_NAMELEN)) - return (0); - strp = &mlp->ml_dirp[0]; - if (!xdr_string(xdrsp, &strp, RPCMNT_PATHLEN)) - return (0); - mlp = mlp->ml_next; - } - if (!xdr_bool(xdrsp, &falseval)) - return (0); - return (1); -} - -/* - * Xdr conversion for export list - */ -int -xdr_explist(xdrsp, cp) - XDR *xdrsp; - caddr_t cp; -{ - struct exportlist *ep; - int falseval = 0; - int putdef; - sigset_t sighup_mask; - - (void)sigemptyset(&sighup_mask); - (void)sigaddset(&sighup_mask, SIGHUP); - (void)sigprocmask(SIG_BLOCK, &sighup_mask, NULL); - ep = exphead; - while (ep) { - putdef = 0; - if (put_exlist(ep->ex_dirl, xdrsp, ep->ex_defdir, &putdef)) - goto errout; - if (ep->ex_defdir && putdef == 0 && - put_exlist(ep->ex_defdir, xdrsp, NULL, &putdef)) - goto errout; - ep = ep->ex_next; - } - (void)sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); - if (!xdr_bool(xdrsp, &falseval)) - return (0); - return (1); -errout: - (void)sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); - return (0); -} - -/* - * Called from xdr_explist() to traverse the tree and export the - * directory paths. Assumes SIGHUP has already been masked. - */ -int -put_exlist(dp, xdrsp, adp, putdefp) - struct dirlist *dp; - XDR *xdrsp; - struct dirlist *adp; - int *putdefp; -{ - struct grouplist *grp; - struct hostlist *hp; - int trueval = 1; - int falseval = 0; - int gotalldir = 0; - char *strp; - - if (dp) { - if (put_exlist(dp->dp_left, xdrsp, adp, putdefp)) - return (1); - if (!xdr_bool(xdrsp, &trueval)) - return (1); - strp = dp->dp_dirp; - if (!xdr_string(xdrsp, &strp, RPCMNT_PATHLEN)) - return (1); - if (adp && !strcmp(dp->dp_dirp, adp->dp_dirp)) { - gotalldir = 1; - *putdefp = 1; - } - if ((dp->dp_flag & DP_DEFSET) == 0 && - (gotalldir == 0 || (adp->dp_flag & DP_DEFSET) == 0)) { - hp = dp->dp_hosts; - while (hp) { - grp = hp->ht_grp; - if (grp->gr_type == GT_HOST) { - if (!xdr_bool(xdrsp, &trueval)) - return (1); - strp = - grp->gr_ptr.gt_addrinfo->ai_canonname; - if (!xdr_string(xdrsp, &strp, - RPCMNT_NAMELEN)) - return (1); - } else if (grp->gr_type == GT_NET) { - if (!xdr_bool(xdrsp, &trueval)) - return (1); - strp = grp->gr_ptr.gt_net.nt_name; - if (!xdr_string(xdrsp, &strp, - RPCMNT_NAMELEN)) - return (1); - } - hp = hp->ht_next; - if (gotalldir && hp == NULL) { - hp = adp->dp_hosts; - gotalldir = 0; - } - } - } - if (!xdr_bool(xdrsp, &falseval)) - return (1); - if (put_exlist(dp->dp_right, xdrsp, adp, putdefp)) - return (1); - } - return (0); -} - -static int -parse_host_netgroup(line, lineno, ep, tgrp, cp, has_host, grp) - const char *line; - size_t lineno; - struct exportlist *ep; - struct grouplist *tgrp; - char *cp; - int *has_host; - struct grouplist **grp; -{ - const char *hst, *usr, *dom; - int netgrp; - - if (ep == NULL) { - syslog(LOG_ERR, "\"%s\", line %ld: No current export", - line, (unsigned long)lineno); - return 0; - } - setnetgrent(cp); - netgrp = getnetgrent(&hst, &usr, &dom); - do { - if (*has_host) { - (*grp)->gr_next = get_grp(); - *grp = (*grp)->gr_next; - } - if (netgrp) { - if (hst == NULL) { - syslog(LOG_ERR, - "\"%s\", line %ld: No host in netgroup %s", - line, (unsigned long)lineno, cp); - goto bad; - } - if (get_host(line, lineno, hst, *grp)) - goto bad; - } else if (get_host(line, lineno, cp, *grp)) - goto bad; - *has_host = TRUE; - } while (netgrp && getnetgrent(&hst, &usr, &dom)); - - endnetgrent(); - return 1; -bad: - endnetgrent(); - return 0; - -} - -static int -parse_directory(line, lineno, tgrp, got_nondir, cp, ep, fsp) - const char *line; - size_t lineno; - struct grouplist *tgrp; - int got_nondir; - char *cp; - struct exportlist **ep; - struct statvfs *fsp; -{ - int error = 0; - - if (!check_dirpath(line, lineno, cp)) - return 0; - - if (rump_sys_statvfs1(cp, fsp, ST_WAIT) == -1) { - syslog(LOG_ERR, "\"%s\", line %ld: statvfs for `%s' failed: %m %d", - line, (unsigned long)lineno, cp, error); - return 0; - } - - if (got_nondir) { - syslog(LOG_ERR, - "\"%s\", line %ld: Directories must precede files", - line, (unsigned long)lineno); - return 0; - } - if (*ep) { - if ((*ep)->ex_fs.__fsid_val[0] != fsp->f_fsidx.__fsid_val[0] || - (*ep)->ex_fs.__fsid_val[1] != fsp->f_fsidx.__fsid_val[1]) { - syslog(LOG_ERR, - "\"%s\", line %ld: filesystem ids disagree", - line, (unsigned long)lineno); - return 0; - } - } else { - /* - * See if this directory is already - * in the list. - */ - *ep = ex_search(&fsp->f_fsidx); - if (*ep == NULL) { - *ep = get_exp(); - (*ep)->ex_fs = fsp->f_fsidx; - (*ep)->ex_fsdir = estrdup(fsp->f_mntonname); - if (debug) - (void)fprintf(stderr, - "Making new ep fs=0x%x,0x%x\n", - fsp->f_fsidx.__fsid_val[0], fsp->f_fsidx.__fsid_val[1]); - } else { - if (debug) - (void)fprintf(stderr, - "Found ep fs=0x%x,0x%x\n", - fsp->f_fsidx.__fsid_val[0], fsp->f_fsidx.__fsid_val[1]); - } - } - - return 1; -} - - -/* - * Get the export list - */ -/* ARGSUSED */ -void -get_exportlist(n) - int n; -{ - struct exportlist *ep, *ep2; - struct grouplist *grp, *tgrp; - struct exportlist **epp; - struct dirlist *dirhead; - struct statvfs fsb, *fsp; - struct addrinfo *ai; - struct uucred anon; - char *cp, *endcp, *dirp, savedc; - int has_host, exflags, got_nondir, dirplen, num, i; - FILE *exp_file; - char *line; - size_t lineno = 0, len; - - - /* - * First, get rid of the old list - */ - ep = exphead; - while (ep) { - ep2 = ep; - ep = ep->ex_next; - free_exp(ep2); - } - exphead = NULL; - - dirp = NULL; - dirplen = 0; - grp = grphead; - while (grp) { - tgrp = grp; - grp = grp->gr_next; - free_grp(tgrp); - } - grphead = NULL; - - /* - * And delete exports that are in the kernel for all local - * file systems. - */ - num = getmntinfo(&fsp, MNT_NOWAIT); - for (i = 0; i < num; i++) { - struct mountd_exports_list mel; - - /* Delete all entries from the export list. */ - mel.mel_path = fsp->f_mntonname; - mel.mel_nexports = 0; - if (rump_sys_nfssvc(NFSSVC_SETEXPORTSLIST, &mel) == -1 && - errno != EOPNOTSUPP) - syslog(LOG_ERR, "Can't delete exports for %s (%m)", - fsp->f_mntonname); - - fsp++; - } - - /* - * Read in the exports file and build the list, calling - * mount() as we go along to push the export rules into the kernel. - */ - exname = _PATH_EXPORTS; - if ((exp_file = rumpfopen(exname, "r")) == NULL) { - /* - * Don't exit here; we can still reload the config - * after a SIGHUP. - */ - if (debug) - (void)fprintf(stderr, "Can't open %s: %s\n", exname, - strerror(errno)); - return; - } - dirhead = NULL; - while ((line = fparseln(exp_file, &len, &lineno, NULL, 0)) != NULL) { - if (debug) - (void)fprintf(stderr, "Got line %s\n", line); - cp = line; - nextfield(&cp, &endcp); - if (cp == endcp) - goto nextline; /* skip empty line */ - /* - * Set defaults. - */ - has_host = FALSE; - anon = def_anon; - exflags = MNT_EXPORTED; - got_nondir = 0; - opt_flags = 0; - ep = NULL; - - if (noprivports) { - opt_flags |= OP_NORESMNT | OP_NORESPORT; - exflags |= MNT_EXNORESPORT; - } - - /* - * Create new exports list entry - */ - len = endcp - cp; - tgrp = grp = get_grp(); - while (len > 0) { - if (len > RPCMNT_NAMELEN) { - *endcp = '\0'; - syslog(LOG_ERR, - "\"%s\", line %ld: name `%s' is too long", - line, (unsigned long)lineno, cp); - goto badline; - } - switch (*cp) { - case '-': - /* - * Option - */ - if (ep == NULL) { - syslog(LOG_ERR, - "\"%s\", line %ld: No current export list", - line, (unsigned long)lineno); - goto badline; - } - if (debug) - (void)fprintf(stderr, "doing opt %s\n", - cp); - got_nondir = 1; - if (do_opt(line, lineno, &cp, &endcp, ep, grp, - &has_host, &exflags, &anon)) - goto badline; - break; - - case '/': - /* - * Directory - */ - savedc = *endcp; - *endcp = '\0'; - - if (!parse_directory(line, lineno, tgrp, - got_nondir, cp, &ep, &fsb)) - goto badline; - /* - * Add dirpath to export mount point. - */ - dirp = add_expdir(&dirhead, cp, len); - dirplen = len; - - *endcp = savedc; - break; - - default: - /* - * Host or netgroup. - */ - savedc = *endcp; - *endcp = '\0'; - - if (!parse_host_netgroup(line, lineno, ep, - tgrp, cp, &has_host, &grp)) - goto badline; - - got_nondir = 1; - - *endcp = savedc; - break; - } - - cp = endcp; - nextfield(&cp, &endcp); - len = endcp - cp; - } - if (check_options(line, lineno, dirhead)) - goto badline; - - if (!has_host) { - grp->gr_type = GT_HOST; - if (debug) - (void)fprintf(stderr, - "Adding a default entry\n"); - /* add a default group and make the grp list NULL */ - ai = emalloc(sizeof(struct addrinfo)); - ai->ai_flags = 0; - ai->ai_family = AF_INET; /* XXXX */ - ai->ai_socktype = SOCK_DGRAM; - /* setting the length to 0 will match anything */ - ai->ai_addrlen = 0; - ai->ai_flags = AI_CANONNAME; - ai->ai_canonname = estrdup("Default"); - ai->ai_addr = NULL; - ai->ai_next = NULL; - grp->gr_ptr.gt_addrinfo = ai; - - } else if ((opt_flags & OP_NET) && tgrp->gr_next) { - /* - * Don't allow a network export coincide with a list of - * host(s) on the same line. - */ - syslog(LOG_ERR, - "\"%s\", line %ld: Mixed exporting of networks and hosts is disallowed", - line, (unsigned long)lineno); - goto badline; - } - /* - * Loop through hosts, pushing the exports into the kernel. - * After loop, tgrp points to the start of the list and - * grp points to the last entry in the list. - */ - grp = tgrp; - do { - if (do_nfssvc(line, lineno, ep, grp, exflags, &anon, - dirp, dirplen, &fsb)) - goto badline; - } while (grp->gr_next && (grp = grp->gr_next)); - - /* - * Success. Update the data structures. - */ - if (has_host) { - hang_dirp(dirhead, tgrp, ep, opt_flags); - grp->gr_next = grphead; - grphead = tgrp; - } else { - hang_dirp(dirhead, NULL, ep, opt_flags); - free_grp(tgrp); - } - tgrp = NULL; - dirhead = NULL; - if ((ep->ex_flag & EX_LINKED) == 0) { - ep2 = exphead; - epp = &exphead; - - /* - * Insert in the list in alphabetical order. - */ - while (ep2 && strcmp(ep2->ex_fsdir, ep->ex_fsdir) < 0) { - epp = &ep2->ex_next; - ep2 = ep2->ex_next; - } - if (ep2) - ep->ex_next = ep2; - *epp = ep; - ep->ex_flag |= EX_LINKED; - } - goto nextline; -badline: - free_exp_grp(ep, grp); -nextline: - if (dirhead) { - free_dir(dirhead); - dirhead = NULL; - } - free(line); - } - (void)fclose(exp_file); -} - -/* - * Allocate an export list element - */ -static struct exportlist * -get_exp() -{ - struct exportlist *ep; - - ep = emalloc(sizeof(struct exportlist)); - (void)memset(ep, 0, sizeof(struct exportlist)); - return (ep); -} - -/* - * Allocate a group list element - */ -static struct grouplist * -get_grp() -{ - struct grouplist *gp; - - gp = emalloc(sizeof(struct grouplist)); - (void)memset(gp, 0, sizeof(struct grouplist)); - return (gp); -} - -/* - * Clean up upon an error in get_exportlist(). - */ -static void -free_exp_grp(ep, grp) - struct exportlist *ep; - struct grouplist *grp; -{ - struct grouplist *tgrp; - - if (ep && (ep->ex_flag & EX_LINKED) == 0) - free_exp(ep); - while (grp) { - tgrp = grp; - grp = grp->gr_next; - free_grp(tgrp); - } -} - -/* - * Search the export list for a matching fs. - */ -static struct exportlist * -ex_search(fsid) - fsid_t *fsid; -{ - struct exportlist *ep; - - ep = exphead; - return ep; - while (ep) { - if (ep->ex_fs.__fsid_val[0] == fsid->__fsid_val[0] && - ep->ex_fs.__fsid_val[1] == fsid->__fsid_val[1]) - return (ep); - ep = ep->ex_next; - } - return (ep); -} - -/* - * Add a directory path to the list. - */ -static char * -add_expdir(dpp, cp, len) - struct dirlist **dpp; - char *cp; - int len; -{ - struct dirlist *dp; - - dp = emalloc(sizeof(struct dirlist) + len); - dp->dp_left = *dpp; - dp->dp_right = NULL; - dp->dp_flag = 0; - dp->dp_hosts = NULL; - (void)strcpy(dp->dp_dirp, cp); - *dpp = dp; - return (dp->dp_dirp); -} - -/* - * Hang the dir list element off the dirpath binary tree as required - * and update the entry for host. - */ -void -hang_dirp(dp, grp, ep, flags) - struct dirlist *dp; - struct grouplist *grp; - struct exportlist *ep; - int flags; -{ - struct hostlist *hp; - struct dirlist *dp2; - - if (flags & OP_ALLDIRS) { - if (ep->ex_defdir) - free(dp); - else - ep->ex_defdir = dp; - if (grp == NULL) { - ep->ex_defdir->dp_flag |= DP_DEFSET; - if (flags & OP_KERB) - ep->ex_defdir->dp_flag |= DP_KERB; - if (flags & OP_NORESMNT) - ep->ex_defdir->dp_flag |= DP_NORESMNT; - } else - while (grp) { - hp = get_ht(); - if (flags & OP_KERB) - hp->ht_flag |= DP_KERB; - if (flags & OP_NORESMNT) - hp->ht_flag |= DP_NORESMNT; - hp->ht_grp = grp; - hp->ht_next = ep->ex_defdir->dp_hosts; - ep->ex_defdir->dp_hosts = hp; - grp = grp->gr_next; - } - } else { - - /* - * Loop through the directories adding them to the tree. - */ - while (dp) { - dp2 = dp->dp_left; - add_dlist(&ep->ex_dirl, dp, grp, flags); - dp = dp2; - } - } -} - -/* - * Traverse the binary tree either updating a node that is already there - * for the new directory or adding the new node. - */ -static void -add_dlist(dpp, newdp, grp, flags) - struct dirlist **dpp; - struct dirlist *newdp; - struct grouplist *grp; - int flags; -{ - struct dirlist *dp; - struct hostlist *hp; - int cmp; - - dp = *dpp; - if (dp) { - cmp = strcmp(dp->dp_dirp, newdp->dp_dirp); - if (cmp > 0) { - add_dlist(&dp->dp_left, newdp, grp, flags); - return; - } else if (cmp < 0) { - add_dlist(&dp->dp_right, newdp, grp, flags); - return; - } else - free(newdp); - } else { - dp = newdp; - dp->dp_left = NULL; - *dpp = dp; - } - if (grp) { - - /* - * Hang all of the host(s) off of the directory point. - */ - do { - hp = get_ht(); - if (flags & OP_KERB) - hp->ht_flag |= DP_KERB; - if (flags & OP_NORESMNT) - hp->ht_flag |= DP_NORESMNT; - hp->ht_grp = grp; - hp->ht_next = dp->dp_hosts; - dp->dp_hosts = hp; - grp = grp->gr_next; - } while (grp); - } else { - dp->dp_flag |= DP_DEFSET; - if (flags & OP_KERB) - dp->dp_flag |= DP_KERB; - if (flags & OP_NORESMNT) - dp->dp_flag |= DP_NORESMNT; - } -} - -/* - * Search for a dirpath on the export point. - */ -static struct dirlist * -dirp_search(dp, dirp) - struct dirlist *dp; - char *dirp; -{ - int cmp; - - if (dp) { - cmp = strcmp(dp->dp_dirp, dirp); - if (cmp > 0) - return (dirp_search(dp->dp_left, dirp)); - else if (cmp < 0) - return (dirp_search(dp->dp_right, dirp)); - else - return (dp); - } - return (dp); -} - -/* - * Some helper functions for netmasks. They all assume masks in network - * order (big endian). - */ -static int -bitcmp(void *dst, void *src, int bitlen) -{ - int i; - u_int8_t *p1 = dst, *p2 = src; - u_int8_t bitmask; - int bytelen, bitsleft; - - bytelen = bitlen / 8; - bitsleft = bitlen % 8; - - if (debug) { - printf("comparing:\n"); - for (i = 0; i < (bitsleft ? bytelen + 1 : bytelen); i++) - printf("%02x", p1[i]); - printf("\n"); - for (i = 0; i < (bitsleft ? bytelen + 1 : bytelen); i++) - printf("%02x", p2[i]); - printf("\n"); - } - - for (i = 0; i < bytelen; i++) { - if (*p1 != *p2) - return 1; - p1++; - p2++; - } - - for (i = 0; i < bitsleft; i++) { - bitmask = 1 << (7 - i); - if ((*p1 & bitmask) != (*p2 & bitmask)) - return 1; - } - - return 0; -} - -static int -netpartcmp(struct sockaddr *s1, struct sockaddr *s2, int bitlen) -{ - void *src, *dst; - - if (s1->sa_family != s2->sa_family) - return 1; - - switch (s1->sa_family) { - case AF_INET: - src = &((struct sockaddr_in *)s1)->sin_addr; - dst = &((struct sockaddr_in *)s2)->sin_addr; - if (bitlen > sizeof(((struct sockaddr_in *)s1)->sin_addr) * 8) - return 1; - break; - case AF_INET6: - src = &((struct sockaddr_in6 *)s1)->sin6_addr; - dst = &((struct sockaddr_in6 *)s2)->sin6_addr; - if (((struct sockaddr_in6 *)s1)->sin6_scope_id != - ((struct sockaddr_in6 *)s2)->sin6_scope_id) - return 1; - if (bitlen > sizeof(((struct sockaddr_in6 *)s1)->sin6_addr) * 8) - return 1; - break; - default: - return 1; - } - - return bitcmp(src, dst, bitlen); -} - -static int -allones(struct sockaddr_storage *ssp, int bitlen) -{ - u_int8_t *p; - int bytelen, bitsleft, i; - int zerolen; - - switch (ssp->ss_family) { - case AF_INET: - p = (u_int8_t *)&((struct sockaddr_in *)ssp)->sin_addr; - zerolen = sizeof (((struct sockaddr_in *)ssp)->sin_addr); - break; - case AF_INET6: - p = (u_int8_t *)&((struct sockaddr_in6 *)ssp)->sin6_addr; - zerolen = sizeof (((struct sockaddr_in6 *)ssp)->sin6_addr); - break; - default: - return -1; - } - - memset(p, 0, zerolen); - - bytelen = bitlen / 8; - bitsleft = bitlen % 8; - - if (bytelen > zerolen) - return -1; - - for (i = 0; i < bytelen; i++) - *p++ = 0xff; - - for (i = 0; i < bitsleft; i++) - *p |= 1 << (7 - i); - - return 0; -} - -static int -countones(struct sockaddr *sa) -{ - void *mask; - int i, bits = 0, bytelen; - u_int8_t *p; - - switch (sa->sa_family) { - case AF_INET: - mask = (u_int8_t *)&((struct sockaddr_in *)sa)->sin_addr; - bytelen = 4; - break; - case AF_INET6: - mask = (u_int8_t *)&((struct sockaddr_in6 *)sa)->sin6_addr; - bytelen = 16; - break; - default: - return 0; - } - - p = mask; - - for (i = 0; i < bytelen; i++, p++) { - if (*p != 0xff) { - for (bits = 0; bits < 8; bits++) { - if (!(*p & (1 << (7 - bits)))) - break; - } - break; - } - } - - return (i * 8 + bits); -} - -static int -sacmp(struct sockaddr *sa1, struct sockaddr *sa2) -{ - void *p1, *p2; - int len; - - if (sa1->sa_family != sa2->sa_family) - return 1; - - switch (sa1->sa_family) { - case AF_INET: - p1 = &((struct sockaddr_in *)sa1)->sin_addr; - p2 = &((struct sockaddr_in *)sa2)->sin_addr; - len = 4; - break; - case AF_INET6: - p1 = &((struct sockaddr_in6 *)sa1)->sin6_addr; - p2 = &((struct sockaddr_in6 *)sa2)->sin6_addr; - len = 16; - if (((struct sockaddr_in6 *)sa1)->sin6_scope_id != - ((struct sockaddr_in6 *)sa2)->sin6_scope_id) - return 1; - break; - default: - return 1; - } - - return memcmp(p1, p2, len); -} - -/* - * Scan for a host match in a directory tree. - */ -static int -chk_host(dp, saddr, defsetp, hostsetp) - struct dirlist *dp; - struct sockaddr *saddr; - int *defsetp; - int *hostsetp; -{ - struct hostlist *hp; - struct grouplist *grp; - struct addrinfo *ai; - - if (dp) { - if (dp->dp_flag & DP_DEFSET) - *defsetp = dp->dp_flag; - hp = dp->dp_hosts; - while (hp) { - grp = hp->ht_grp; - switch (grp->gr_type) { - case GT_HOST: - ai = grp->gr_ptr.gt_addrinfo; - for (; ai; ai = ai->ai_next) { - if (!sacmp(ai->ai_addr, saddr)) { - *hostsetp = - (hp->ht_flag | DP_HOSTSET); - return (1); - } - } - break; - case GT_NET: - if (!netpartcmp(saddr, - (struct sockaddr *) - &grp->gr_ptr.gt_net.nt_net, - grp->gr_ptr.gt_net.nt_len)) { - *hostsetp = (hp->ht_flag | DP_HOSTSET); - return (1); - } - break; - }; - hp = hp->ht_next; - } - } - return (0); -} - -/* - * Scan tree for a host that matches the address. - */ -static int -scan_tree(dp, saddr) - struct dirlist *dp; - struct sockaddr *saddr; -{ - int defset, hostset; - - if (dp) { - if (scan_tree(dp->dp_left, saddr)) - return (1); - if (chk_host(dp, saddr, &defset, &hostset)) - return (1); - if (scan_tree(dp->dp_right, saddr)) - return (1); - } - return (0); -} - -/* - * Traverse the dirlist tree and free it up. - */ -static void -free_dir(dp) - struct dirlist *dp; -{ - - if (dp) { - free_dir(dp->dp_left); - free_dir(dp->dp_right); - free_host(dp->dp_hosts); - free(dp); - } -} - -/* - * Parse the option string and update fields. - * Option arguments may either be -
&1$,4R/;TW5?@V<'3M.?S]?=,= +MMI5J+Q)IRU0N8EP%R10&`H%Q)C808%R%S"F)"XN$9=K&//F-7KXC@4X7@G<< +M/`BIC@08IP`<`E9"R`=Q!)W!!)>"BP[EG`IP2[-W:O%W4TZOA^'U_5^B]3PO +M6>'V=_H7];EZVML:VP*:]:VNA>)KDUXTT$UHA%!A->(%C"@FE-"1'2HUR]T& +MN;LX=.SO.]X1N]CFY;CC&+);+;JA4N1EP&)4@R2YE,-)AA(DG*%L`*2L*P#E +M(\M(RV\@AQ,G1YHWN`&).GJ@ +M(2QBP!(I[9`C)-;$8+(,.);36@,GJJ,)#"1'2I-,!:HK1I4J0^>MX/'Q9:S7KUUG&+-=:)#6C$@R>X8L4(A*R37`UH +MZDUFOCFLXSPY%6VW9L#48>IFF7H +M(`I57A?FOIH63-$!(7LO8&9D+))8(H2,EZC(DS5I6&!#!8MYN!Q'<.6?8<%W +M(WN-M:N4KQZTR3)$UZJ9281)DP*)*2(A-5Y?/Z''W-75GH&9PK/4$S@9XR,#.,!(=N8K=JW$8C$XL6*;N.K,:%D,:U8-A0MD!RK1H" +M0R6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E`Y;&DU,7U0]BB(@SF,#?$X"S:[ZWZ;?##S]/:.EM;R+\[!7)6`)*;Y) +MO\9Q?9T)`@D,8&,8P,8))[Y5(@3H#&,8P,PF(Z[H9MWSG1Z`MWE3#(#!(0Z[^<"%UJ_/$N7C^=F=5,B) +9@#N8461T+A7W1J)TTW_Q=R13A0D`S39&D(#! ` end diff --git a/contrib/netbsd-tests/dev/cgd/t_cgd_3des.c b/contrib/netbsd-tests/dev/cgd/t_cgd_3des.c new file mode 100644 index 0000000..91e81f4 --- /dev/null +++ b/contrib/netbsd-tests/dev/cgd/t_cgd_3des.c @@ -0,0 +1,913 @@ +/* $NetBSD: t_cgd_3des.c,v 1.1 2016/11/11 07:39:58 alnsn Exp $ */ +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Alexander Nasonov. + * + * 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 COPYRIGHT HOLDERS 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 + * COPYRIGHT HOLDERS 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. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "../../h_macros.h" + +#define SECSIZE 512 + +struct testvec { + unsigned int blkno; + const uint8_t *ptxt; /* PlainText */ + const uint8_t *ctxt; /* CipherText */ +}; + +/* + * 192 bits CBC key, NUL terminated. + */ +static const char c3des_cbc_192_key[25] = { + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, /* ABCDEFGH */ + 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* IJKLMNOP */ + 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* QRSTUVWX */ + 0 +}; + +static const uint8_t c3des_cbc_ptxt[SECSIZE] = + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop"; + +/* + * IV method encblkno1, blkno 0. + */ +static const uint8_t c3des_cbc_192_encblkno1_vec0_ctxt[SECSIZE] = { + 0x19, 0x92, 0xc8, 0xce, 0xdf, 0xa3, 0x14, 0xef, + 0xff, 0x88, 0x9f, 0x01, 0xfa, 0x6f, 0xfa, 0xa6, + 0xdd, 0x2b, 0x43, 0x67, 0xfa, 0xce, 0x37, 0x95, + 0x73, 0x4d, 0x18, 0x33, 0x0c, 0x29, 0xb6, 0xbb, + 0x37, 0x77, 0x31, 0x74, 0xf6, 0x62, 0x03, 0xd2, + 0x78, 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f, + 0xec, 0x3a, 0xbc, 0x8e, 0xe6, 0xb3, 0x2b, 0x43, + 0xcd, 0x67, 0x8b, 0x72, 0x00, 0x6f, 0xe5, 0x85, + 0xe2, 0x2a, 0x4c, 0x8d, 0x02, 0x44, 0x6b, 0x7a, + 0x89, 0x7a, 0x18, 0x3b, 0xc8, 0x9c, 0x8d, 0x60, + 0xec, 0x79, 0x58, 0x15, 0x98, 0x71, 0x4b, 0x1a, + 0x34, 0x69, 0x96, 0xd0, 0x0f, 0x01, 0x27, 0x2e, + 0x19, 0x02, 0xf0, 0x17, 0x8c, 0x89, 0xbf, 0x05, + 0xf0, 0xfe, 0xc3, 0xe6, 0x90, 0x9d, 0xa2, 0xb1, + 0x40, 0x06, 0x7e, 0xcd, 0x20, 0x7e, 0x5f, 0x54, + 0x31, 0xfb, 0x79, 0x84, 0x47, 0x38, 0x71, 0x69, + 0xe1, 0xd5, 0x4e, 0x84, 0xa3, 0x2b, 0x4a, 0x86, + 0xc2, 0x21, 0x5b, 0x15, 0xc3, 0x63, 0xbb, 0xc5, + 0x5c, 0xc1, 0xfb, 0x31, 0x3a, 0x4d, 0xb1, 0x9e, + 0xe1, 0xd8, 0x67, 0x4b, 0x08, 0x42, 0xc4, 0xe8, +}; + +/* + * IV method encblkno1, blkno 1. + */ +static const uint8_t c3des_cbc_192_encblkno1_vec1_ctxt[SECSIZE] = { + 0x1d, 0x65, 0xdf, 0x01, 0x9b, 0x24, 0xa5, 0x10, + 0x94, 0x9a, 0x5b, 0x81, 0x96, 0x4e, 0xa3, 0x42, + 0x42, 0xd5, 0x05, 0x52, 0xab, 0x3c, 0x67, 0x40, + 0x79, 0xf9, 0x4b, 0x58, 0x39, 0xf6, 0xd0, 0x97, + 0x48, 0xf4, 0x77, 0xb8, 0xac, 0xe2, 0x10, 0x66, + 0xa8, 0x04, 0x0a, 0x1e, 0xa6, 0xbb, 0x4c, 0xd9, + 0x5d, 0x0c, 0x11, 0xb5, 0xe0, 0x26, 0x84, 0x50, + 0x10, 0x80, 0xbf, 0xd6, 0xdc, 0x82, 0x53, 0x0a, + 0xcf, 0xf6, 0xd3, 0x07, 0x45, 0xb0, 0x8e, 0x36, + 0x2e, 0x60, 0x0f, 0xd0, 0xc1, 0xb9, 0xd8, 0x29, + 0x6e, 0x13, 0x8e, 0xc1, 0xa8, 0x63, 0x20, 0xe0, + 0x8d, 0x47, 0x8b, 0xf9, 0xa0, 0x60, 0x55, 0x53, + 0x1d, 0xaf, 0x43, 0x46, 0xe5, 0x10, 0xd5, 0xcd, + 0x91, 0x9e, 0x11, 0x4a, 0x6f, 0x6a, 0x13, 0xdf, + 0xee, 0x7a, 0x88, 0xbe, 0x59, 0x96, 0xdb, 0x65, + 0x25, 0x57, 0x9e, 0x82, 0xad, 0xc2, 0xd6, 0x28, + 0x96, 0xb3, 0x7f, 0x57, 0x5d, 0xb2, 0xfa, 0x60, + 0x43, 0x22, 0xa5, 0x33, 0x14, 0x99, 0x8f, 0x68, + 0x5a, 0x7f, 0xaf, 0x9e, 0xe9, 0x23, 0x57, 0x9b, + 0x52, 0xe9, 0x20, 0x59, 0x26, 0x89, 0x9b, 0x59, + 0xb0, 0xee, 0xe8, 0x6d, 0x06, 0x8c, 0x01, 0xc2, + 0xea, 0xbc, 0x7d, 0x93, 0x3f, 0x79, 0x7f, 0xeb, + 0x57, 0xc9, 0x0a, 0xca, 0x37, 0x81, 0xa7, 0x82, + 0xde, 0x37, 0x7d, 0x69, 0x01, 0xaa, 0x19, 0x98, + 0x26, 0xfe, 0x06, 0x83, 0xeb, 0x9d, 0x26, 0xdc, + 0x04, 0x5d, 0xc9, 0x05, 0xee, 0x1a, 0xd3, 0xeb, + 0x20, 0x8c, 0xb7, 0x99, 0x75, 0xe0, 0x19, 0x98, + 0xca, 0x83, 0xae, 0x94, 0x28, 0xbf, 0x47, 0x42, + 0x92, 0x05, 0x8c, 0xaa, 0xeb, 0x99, 0x0f, 0xcc, + 0x33, 0x79, 0x24, 0x62, 0xa0, 0x7a, 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0xad, 0x60, 0x8d, 0xe9, 0xe2, 0x9d, + 0x3c, 0xea, 0x09, 0x51, 0x3c, 0x81, 0xdf, 0x1a, + 0xc2, 0xc2, 0xf6, 0x45, 0xe1, 0x73, 0xac, 0xae, + 0x85, 0x74, 0x83, 0x8f, 0x56, 0x3c, 0x36, 0x1c, + 0xe0, 0x07, 0xc6, 0x6a, 0x48, 0xe4, 0x34, 0xe9, + 0x81, 0x53, 0xb7, 0x53, 0x95, 0xa7, 0x94, 0x21, + 0x7e, 0x32, 0x53, 0xda, 0x83, 0xd8, 0x57, 0x92, + 0xd1, 0x15, 0x45, 0x86, 0x40, 0xac, 0xf1, 0x6f, + 0x3c, 0x29, 0xef, 0x8d, 0x12, 0xe1, 0x9d, 0x04, + 0x17, 0x3a, 0xcc, 0xa6, 0xc5, 0xe4, 0x27, 0x41, + 0xcb, 0xfb, 0x5e, 0x77, 0x73, 0x5a, 0x2c, 0x03, + 0xe9, 0x2b, 0x76, 0x4e, 0x69, 0xea, 0xcb, 0xb3, +}; + +/* + * IV method encblkno1, blkno 2. + */ +static const uint8_t c3des_cbc_192_encblkno1_vec2_ctxt[SECSIZE] = { + 0x87, 0xb1, 0x3c, 0xd6, 0x60, 0xa0, 0x5a, 0x35, + 0xf7, 0xe1, 0x6b, 0x87, 0xa0, 0x90, 0x2f, 0xc7, + 0x8c, 0xed, 0x53, 0xda, 0x93, 0x32, 0x78, 0x5d, + 0x24, 0x23, 0x42, 0xdd, 0x93, 0x5b, 0x2e, 0x40, + 0xa1, 0xb1, 0x3b, 0xbb, 0xf0, 0x50, 0xb4, 0x61, + 0xea, 0x15, 0x37, 0xf3, 0x49, 0xe1, 0xa0, 0x32, + 0x88, 0x85, 0x81, 0xfd, 0xb7, 0x96, 0xd7, 0x9d, + 0xd7, 0x29, 0x4b, 0x14, 0xf9, 0x18, 0x6a, 0xf6, + 0x46, 0xae, 0x69, 0xdf, 0x63, 0x9a, 0xe0, 0x0b, + 0x2c, 0x53, 0xd7, 0x82, 0x6f, 0xe5, 0xa0, 0x95, + 0x2f, 0x61, 0x7f, 0x15, 0xff, 0xc7, 0xe8, 0x83, + 0xfc, 0xfc, 0x16, 0x1c, 0x37, 0x0f, 0x9b, 0xbb, + 0x14, 0xb2, 0xe2, 0xb7, 0x1f, 0x85, 0xb7, 0x07, + 0x8a, 0x18, 0xed, 0xf7, 0x5f, 0x27, 0xff, 0x2f, + 0x07, 0xf9, 0x9d, 0xe3, 0x79, 0x45, 0x1f, 0x51, + 0x08, 0x54, 0x0f, 0x56, 0x84, 0xee, 0x87, 0x9a, + 0xa9, 0x46, 0xb8, 0x77, 0x85, 0x40, 0x46, 0x50, + 0xc1, 0x58, 0x07, 0xfd, 0xfa, 0x2b, 0x20, 0xd6, + 0x4e, 0xba, 0x08, 0x02, 0x59, 0x3d, 0x23, 0x3b, + 0x5d, 0xf9, 0x5e, 0x2f, 0xac, 0x9e, 0xa0, 0xd7, + 0x3f, 0x9a, 0xdf, 0x50, 0x66, 0xcc, 0x28, 0xce, + 0x93, 0xc8, 0x11, 0x5c, 0x74, 0xe2, 0x4f, 0xfd, + 0xaf, 0x33, 0xbb, 0xce, 0x96, 0x1f, 0xb3, 0x46, + 0x6e, 0xcd, 0xe4, 0xef, 0xfa, 0x2f, 0x93, 0xb1, + 0xe5, 0x7c, 0x54, 0xbc, 0x17, 0x1f, 0xd5, 0x31, + 0x0e, 0x88, 0xe7, 0xcd, 0xb0, 0xb5, 0x2e, 0x1e, + 0x9e, 0x40, 0x36, 0xa5, 0xbb, 0xa7, 0x4e, 0xc8, + 0x11, 0x6c, 0xae, 0x1c, 0x2d, 0xdb, 0x55, 0xd8, + 0x14, 0x40, 0x02, 0xad, 0xaf, 0x19, 0x28, 0x59, + 0xd7, 0x4f, 0x81, 0xd0, 0xc1, 0x54, 0x63, 0x73, + 0x0e, 0xfb, 0x26, 0xf2, 0xa6, 0x80, 0xca, 0x2e, + 0xf3, 0xca, 0x1e, 0xa4, 0x62, 0x07, 0x22, 0x10, + 0x11, 0x6a, 0x57, 0x28, 0x45, 0x80, 0xdf, 0x34, + 0x88, 0xe5, 0xf1, 0x23, 0xe0, 0xb6, 0x44, 0x51, + 0x54, 0xd8, 0xb3, 0x66, 0xac, 0x46, 0x4d, 0xdf, + 0xa2, 0x8e, 0x72, 0x3a, 0x1c, 0x87, 0x2a, 0x43, + 0xfe, 0xdb, 0x00, 0xff, 0xb7, 0x1c, 0x13, 0xc3, + 0x18, 0xfc, 0x71, 0x13, 0xe3, 0xd1, 0x1f, 0xde, + 0x16, 0x63, 0x73, 0xf5, 0x0e, 0xf7, 0x18, 0xe5, + 0x48, 0x8d, 0x30, 0xd9, 0x26, 0x20, 0x6d, 0xa1, + 0xba, 0xde, 0xe8, 0x7d, 0x77, 0x02, 0x33, 0x0d, + 0x73, 0xb2, 0xab, 0x35, 0xfd, 0xa5, 0x6e, 0x4c, + 0x5c, 0x27, 0xc7, 0x7e, 0x4a, 0x28, 0xf8, 0xf5, + 0x00, 0xbe, 0x4c, 0xd7, 0x2c, 0x27, 0x83, 0x16, + 0x37, 0xda, 0x0c, 0xb1, 0xd7, 0x89, 0xd8, 0x8f, + 0x17, 0x69, 0x1b, 0x6b, 0x48, 0x2b, 0xce, 0x9c, + 0xbd, 0xf4, 0x0d, 0xb5, 0x4d, 0x12, 0x11, 0x36, + 0x49, 0xd3, 0x8b, 0x52, 0xce, 0x7e, 0x47, 0xb0, + 0xb5, 0x54, 0x77, 0xef, 0x90, 0xb8, 0x0e, 0xaf, + 0x6f, 0x97, 0x88, 0xde, 0x6b, 0x37, 0x24, 0xdd, + 0x91, 0x84, 0x00, 0x51, 0xab, 0x06, 0x96, 0x3c, + 0x82, 0x73, 0xcf, 0xae, 0x8d, 0x23, 0x86, 0x59, + 0x62, 0x5b, 0xeb, 0x2a, 0xaf, 0x40, 0x17, 0xed, + 0x2b, 0x60, 0x73, 0x7d, 0x99, 0x95, 0x3f, 0xd6, + 0x6c, 0xca, 0x1e, 0xf3, 0xb0, 0xcd, 0xd5, 0x1d, + 0x53, 0xe0, 0xd2, 0x8b, 0x57, 0x7b, 0xac, 0x67, + 0x5a, 0x5a, 0x0a, 0x64, 0x82, 0xab, 0x8f, 0x5a, + 0x36, 0xe2, 0x45, 0x50, 0xec, 0x3e, 0x14, 0x80, + 0x7c, 0xfd, 0x0c, 0xa9, 0x94, 0xfb, 0xfe, 0x72, + 0xec, 0x47, 0x71, 0x2e, 0x90, 0x97, 0xf6, 0x33, + 0xbd, 0x7d, 0x7e, 0x77, 0x8f, 0xad, 0xd4, 0x1d, + 0x1d, 0x53, 0x0f, 0x28, 0x39, 0x77, 0x06, 0x1a, + 0x75, 0xfc, 0x12, 0xe6, 0x45, 0xfc, 0x87, 0xe1, + 0x46, 0xac, 0xb0, 0x73, 0xca, 0x24, 0x7c, 0x71, +}; + +/* + * IV method encblkno1, blkno 3. + */ +static const uint8_t c3des_cbc_192_encblkno1_vec3_ctxt[SECSIZE] = { + 0xb1, 0xef, 0x7c, 0xd0, 0xa0, 0x6b, 0xe4, 0x88, + 0x5c, 0xd7, 0xf1, 0xbf, 0x5f, 0xce, 0xda, 0x19, + 0x81, 0x32, 0xbb, 0x96, 0x7e, 0xb9, 0x6e, 0xa1, + 0x43, 0xde, 0x53, 0x66, 0x9c, 0x27, 0x94, 0x85, + 0xcb, 0x09, 0x4e, 0x16, 0xd8, 0x60, 0x7a, 0x38, + 0x27, 0x21, 0x4d, 0x08, 0xaa, 0xe2, 0x1e, 0x6e, + 0xa3, 0xcb, 0x9a, 0x7f, 0xd1, 0xbf, 0x18, 0x36, + 0x5a, 0x4d, 0x7a, 0x7f, 0xcf, 0x3f, 0xba, 0xa5, + 0x77, 0x5b, 0xb4, 0x79, 0xdc, 0xbf, 0x2a, 0x28, + 0x16, 0x27, 0x0f, 0x8b, 0xd7, 0x95, 0xc3, 0xcb, + 0xa1, 0x6a, 0x49, 0x53, 0xa8, 0x0c, 0x70, 0xde, + 0x90, 0x2e, 0x36, 0x74, 0x40, 0x5d, 0x81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 0x67, 0x68, 0x6e, 0x4b, 0x4d, 0x52, + 0xbc, 0x9b, 0xa2, 0xd8, 0x29, 0x1e, 0x5c, 0xd7, + 0x59, 0x67, 0x94, 0x40, 0x9e, 0x08, 0x15, 0x0d, + 0x7e, 0xc9, 0x14, 0x53, 0xa8, 0x67, 0xb3, 0xb8, + 0xaa, 0x21, 0x0f, 0x79, 0x69, 0x48, 0x52, 0xea, + 0x56, 0x03, 0x7b, 0x55, 0xb7, 0xf3, 0xfe, 0xb1, + 0x8a, 0x22, 0x7d, 0x75, 0x55, 0x31, 0xad, 0x20, + 0x6a, 0xc2, 0xa4, 0xd1, 0x1e, 0xab, 0xdd, 0x29, + 0xb5, 0xf8, 0xdd, 0x9b, 0x1a, 0xb8, 0xe7, 0xde, + 0xae, 0xa1, 0xab, 0xbb, 0xf6, 0x00, 0x87, 0xc4, + 0x29, 0xee, 0x2b, 0xa1, 0xa9, 0x1a, 0x46, 0x05, + 0x5a, 0x12, 0x3f, 0x32, 0x81, 0x25, 0x20, 0x71, + 0xb6, 0xfa, 0x1f, 0x27, 0x2a, 0x33, 0x49, 0xfc, + 0x95, 0x00, 0x72, 0x6b, 0x03, 0x53, 0x94, 0x57, + 0x2f, 0x47, 0x3d, 0x2d, 0x7c, 0xb4, 0xde, 0xa7, + 0x96, 0x81, 0x12, 0xff, 0x2c, 0xec, 0x5c, 0x03, + 0x2a, 0x8c, 0x76, 0xc4, 0xed, 0x09, 0xe6, 0x00, + 0x28, 0xdb, 0x9b, 0x44, 0xb0, 0xb4, 0x7b, 0x57, + 0x3b, 0xb6, 0x4f, 0x0b, 0xff, 0xf2, 0xf5, 0x02, + 0x56, 0xcf, 0xd5, 0xbf, 0x71, 0xe6, 0x66, 0xf3, + 0x08, 0x8e, 0x8b, 0x15, 0x57, 0x07, 0x41, 0xa3, + 0x91, 0xc1, 0xe4, 0x64, 0x92, 0x89, 0xed, 0x22, + 0x88, 0x8f, 0x17, 0x91, 0xde, 0xea, 0x0c, 0xa6, + 0x86, 0x8e, 0x4c, 0xd9, 0x63, 0xc9, 0xe5, 0xdc, + 0xd6, 0xd3, 0x7b, 0x2b, 0x65, 0xfa, 0x36, 0x47, + 0x20, 0xa4, 0xe7, 0x0b, 0x52, 0xfa, 0xa6, 0xeb, + 0x1d, 0x20, 0xd0, 0x4b, 0xfd, 0x88, 0x8c, 0xbb, + 0x52, 0x9c, 0x2f, 0xb7, 0xba, 0x8b, 0xdd, 0x10, + 0x2d, 0x7d, 0x77, 0x79, 0x40, 0xa7, 0xed, 0xf9, + 0xbd, 0x2a, 0x55, 0x1f, 0x87, 0x1e, 0x3c, 0xfc, +}; + +const struct testvec c3des_cbc_192_1_vectors[] = { + { + .blkno = 0, + .ptxt = c3des_cbc_ptxt, + .ctxt = c3des_cbc_192_encblkno1_vec0_ctxt, + }, + { + .blkno = 1, + .ptxt = c3des_cbc_ptxt, + .ctxt = c3des_cbc_192_encblkno1_vec1_ctxt, + }, + { + .blkno = 2, + .ptxt = c3des_cbc_ptxt, + .ctxt = c3des_cbc_192_encblkno1_vec2_ctxt, + }, + { + .blkno = 3, + .ptxt = c3des_cbc_ptxt, + .ctxt = c3des_cbc_192_encblkno1_vec3_ctxt, + }, +}; + +/* + * IV method encblkno8, blkno 0. + */ +static const uint8_t c3des_cbc_192_encblkno8_vec0_ctxt[SECSIZE] = { + 0x9e, 0x5d, 0x35, 0x56, 0xa7, 0xcc, 0xc0, 0x1c, + 0x60, 0x4c, 0x42, 0x90, 0x35, 0xf3, 0xc1, 0x20, + 0xf2, 0x07, 0x6f, 0xf8, 0x7c, 0x33, 0x6a, 0x74, + 0xdc, 0x85, 0xbc, 0x9c, 0xa2, 0x29, 0xc6, 0x69, + 0x0e, 0xef, 0x0f, 0xa9, 0x6e, 0xec, 0xf2, 0x23, + 0x2f, 0x9a, 0xbe, 0x1a, 0x89, 0x22, 0x00, 0xc4, + 0x5a, 0xaf, 0x4a, 0xa0, 0x4f, 0x30, 0x8f, 0x99, + 0xd2, 0x93, 0x6d, 0xfa, 0xcd, 0x2f, 0xad, 0x19, + 0x10, 0x14, 0x90, 0x3a, 0x4b, 0xab, 0x17, 0x2e, + 0x2c, 0xe1, 0x26, 0xe5, 0x76, 0xf1, 0xd1, 0x1d, + 0x4c, 0x77, 0x68, 0xfb, 0x45, 0x9a, 0x3e, 0x19, + 0xe0, 0xfb, 0xdc, 0xd4, 0x0e, 0x29, 0x7c, 0x06, + 0xd3, 0x45, 0xa8, 0xf7, 0x39, 0x91, 0xe6, 0x18, + 0x0f, 0x81, 0xe6, 0x7d, 0x6c, 0x65, 0x2e, 0x16, + 0x24, 0xa4, 0x16, 0x96, 0x0a, 0x7b, 0x5f, 0x3a, + 0x0c, 0xe9, 0x0e, 0x3f, 0x34, 0x38, 0xb0, 0xe1, + 0x39, 0x23, 0x5c, 0x3c, 0x00, 0xb4, 0xa0, 0xf7, + 0x42, 0x18, 0x70, 0x25, 0x82, 0x13, 0x24, 0x49, + 0xbb, 0x3f, 0xfb, 0xef, 0xb6, 0xc6, 0x7f, 0x3d, + 0x8c, 0x17, 0x62, 0x60, 0x6f, 0xd5, 0xda, 0x2c, + 0xf8, 0x85, 0xee, 0xa7, 0xc2, 0x76, 0x5d, 0x34, + 0x4c, 0xe1, 0x0d, 0x36, 0x6e, 0x02, 0xdd, 0x08, + 0x85, 0xe4, 0x90, 0xfe, 0x1f, 0x81, 0x4a, 0x06, + 0xa6, 0x72, 0x81, 0x79, 0x47, 0xd7, 0x6d, 0x92, + 0x8f, 0xb7, 0xb2, 0xfd, 0xd0, 0x60, 0x6c, 0x06, + 0x44, 0xcd, 0x20, 0x28, 0xef, 0x16, 0xc3, 0x01, + 0x19, 0x14, 0x34, 0x39, 0xad, 0x87, 0x9f, 0xde, + 0x76, 0xb9, 0xb9, 0x87, 0x1a, 0xbd, 0x8e, 0x2c, + 0xe6, 0xb3, 0xe7, 0xb6, 0x80, 0xf8, 0xc5, 0x22, + 0x5f, 0x53, 0xed, 0x03, 0xfe, 0x09, 0x2c, 0x9d, + 0xb6, 0x61, 0x4a, 0xbb, 0x07, 0x5d, 0xbd, 0x68, + 0x74, 0xab, 0x02, 0x81, 0x64, 0x7b, 0x97, 0xa3, + 0xad, 0x15, 0x99, 0x7a, 0x04, 0x33, 0xbd, 0x50, + 0x94, 0x11, 0xcc, 0xf7, 0x8b, 0x77, 0x88, 0x78, + 0x80, 0xfe, 0x5f, 0xa1, 0x63, 0xbc, 0xb0, 0x65, + 0xcb, 0x9d, 0x4c, 0xfe, 0x66, 0x4e, 0xff, 0xe3, + 0x43, 0x61, 0x99, 0x88, 0x88, 0x4c, 0xbc, 0x8a, + 0xf1, 0x69, 0x00, 0xc2, 0xe5, 0xb9, 0x65, 0x8b, + 0x10, 0xdf, 0x38, 0x3e, 0x9e, 0x9f, 0x87, 0xed, + 0x84, 0x71, 0xe7, 0xf2, 0xb5, 0xb6, 0x11, 0xed, + 0x1e, 0xd4, 0xc0, 0x6d, 0x77, 0x08, 0x4b, 0xfd, + 0x95, 0xd5, 0xc0, 0xbe, 0xa6, 0xcc, 0x3b, 0xea, + 0x11, 0x38, 0xa5, 0x59, 0x36, 0x2a, 0xf4, 0x98, + 0x52, 0x9d, 0x3b, 0x8c, 0x8a, 0x19, 0xbd, 0xfb, + 0x49, 0xcb, 0xb0, 0x57, 0x91, 0xc7, 0xf8, 0x2a, + 0x89, 0xa8, 0x85, 0x03, 0xdf, 0x6e, 0xad, 0xf4, + 0x8a, 0x88, 0x9a, 0x2b, 0x5d, 0xe8, 0xca, 0xa9, + 0x8f, 0x18, 0xa3, 0x6a, 0x37, 0x84, 0xa9, 0x24, + 0x5b, 0xce, 0xd6, 0xbe, 0x7e, 0x40, 0x86, 0x6a, + 0xc3, 0x47, 0x28, 0x66, 0xf0, 0x8c, 0x2d, 0x69, + 0x22, 0x64, 0x61, 0x36, 0x6a, 0x0c, 0xc4, 0x18, + 0x5f, 0xd7, 0xff, 0xbc, 0xf1, 0x94, 0x16, 0xfb, + 0x26, 0xa7, 0x80, 0xa4, 0x2d, 0x72, 0xc6, 0x9d, + 0xa7, 0xed, 0x04, 0x13, 0x0f, 0xe7, 0xf8, 0x93, + 0x57, 0x6b, 0xd5, 0xa4, 0xad, 0x9a, 0x97, 0xeb, + 0x97, 0xe7, 0x60, 0x01, 0x89, 0x3f, 0x88, 0xf2, + 0xee, 0xf3, 0x79, 0xd6, 0x5a, 0x03, 0x94, 0x07, + 0xd3, 0x33, 0xc8, 0xda, 0x15, 0x17, 0x0a, 0x8f, + 0xbd, 0x58, 0x1b, 0xfe, 0x3d, 0x77, 0x5d, 0x8f, + 0x4e, 0x0e, 0x98, 0x7d, 0x02, 0x63, 0x94, 0x73, + 0x4a, 0x58, 0x47, 0xed, 0x52, 0xfc, 0x85, 0x19, + 0x5d, 0x2f, 0xfa, 0x07, 0x44, 0xbd, 0x8e, 0xcb, + 0x20, 0x63, 0x9d, 0x2b, 0x61, 0x5c, 0x19, 0x71, + 0x80, 0xe5, 0x25, 0x5b, 0x2e, 0xc5, 0xfe, 0x1a, +}; + +/* + * IV method encblkno8, blkno 1. + */ +static const uint8_t c3des_cbc_192_encblkno8_vec1_ctxt[SECSIZE] = { + 0xf4, 0xb0, 0xb0, 0xcb, 0x79, 0xcc, 0x8c, 0x0a, + 0x3b, 0xc7, 0x43, 0x4e, 0x62, 0x9d, 0xde, 0xb4, + 0xab, 0xa5, 0x62, 0x63, 0x32, 0xa7, 0x18, 0x2b, + 0xe3, 0xee, 0x44, 0xc6, 0x6f, 0xb2, 0xdc, 0x21, + 0xc5, 0xc8, 0x9e, 0x32, 0x71, 0x4c, 0x7a, 0x82, + 0x8d, 0xe0, 0xad, 0x91, 0x88, 0x0c, 0x41, 0x83, + 0x28, 0x0d, 0xed, 0xa7, 0xeb, 0x48, 0xb1, 0x31, + 0xfa, 0x40, 0xd9, 0x44, 0x19, 0xee, 0x8d, 0x2c, + 0x7d, 0xe2, 0x39, 0xa0, 0x39, 0xaa, 0x86, 0xab, + 0xb5, 0x68, 0xe5, 0x83, 0x06, 0x61, 0xec, 0xe6, + 0xc2, 0x85, 0xb2, 0x46, 0xf4, 0x5b, 0x0e, 0x34, + 0x7e, 0x0c, 0xa0, 0xda, 0xef, 0x58, 0x9c, 0x39, + 0x95, 0xa2, 0xca, 0xd3, 0x3b, 0x4d, 0x76, 0xe3, + 0x34, 0x6d, 0x08, 0xa4, 0xba, 0x88, 0x58, 0x39, + 0xb4, 0xe4, 0x6b, 0xb6, 0x32, 0x50, 0x2c, 0xe2, + 0x0a, 0x37, 0xbc, 0x98, 0x38, 0x32, 0x17, 0x1b, + 0x12, 0xef, 0xdc, 0x9d, 0x91, 0x09, 0x8e, 0xd8, + 0xc3, 0xf8, 0x7b, 0x35, 0x41, 0x3b, 0xf8, 0xf5, + 0x37, 0x48, 0x04, 0xf7, 0x94, 0xbf, 0x54, 0x8d, + 0x79, 0x49, 0x8f, 0xf0, 0x3f, 0xb7, 0x90, 0x76, + 0x14, 0x09, 0xc6, 0x8c, 0xba, 0x1a, 0x30, 0x1b, + 0xbb, 0xd9, 0xe2, 0xb5, 0xe8, 0xd9, 0x9b, 0x68, + 0x60, 0x90, 0xd3, 0x4a, 0xe8, 0x65, 0x7b, 0xaa, + 0xb0, 0xda, 0x69, 0x1d, 0x45, 0x78, 0x2c, 0x3b, + 0x59, 0x29, 0x3c, 0x26, 0x9a, 0xd2, 0xa5, 0xfd, + 0xb7, 0x16, 0x59, 0x7c, 0x46, 0xea, 0x99, 0xd0, + 0x06, 0x01, 0x3f, 0xd2, 0x23, 0xcc, 0xde, 0xb8, + 0xaa, 0x88, 0x17, 0x03, 0xe1, 0x48, 0x2c, 0xdd, + 0xce, 0xd1, 0x2c, 0xce, 0x37, 0xee, 0xe6, 0xa6, + 0x47, 0x8c, 0x07, 0xe5, 0xfe, 0x01, 0xc6, 0x27, + 0xfe, 0x3f, 0x9d, 0x30, 0x18, 0x36, 0xe7, 0xa7, + 0x37, 0x1d, 0xcf, 0x6d, 0x4c, 0x82, 0xec, 0x58, + 0xa1, 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5b, 0x1c, 0xd0, + 0xf6, 0x47, 0x48, 0x22, 0xf4, 0x6e, 0x38, 0xc5, + 0xab, 0xe2, 0xd0, 0x4d, 0x40, 0x27, 0xab, 0x8f, + 0x43, 0xb1, 0x60, 0x29, 0x07, 0xd0, 0xf5, 0x25, + 0xe5, 0xfa, 0xe7, 0x46, 0x32, 0x37, 0xb9, 0xae, + 0x2e, 0x02, 0x8c, 0x94, 0x15, 0x69, 0xd6, 0x74, + 0xb4, 0x36, 0xdd, 0x94, 0x70, 0xa7, 0x16, 0x7b, + 0x4c, 0xd3, 0x48, 0x83, 0xc5, 0xb2, 0xb0, 0x6a, + 0xfe, 0x7e, 0xd4, 0xe5, 0x6d, 0xa5, 0x96, 0x20, + 0x08, 0x59, 0xbd, 0x0c, 0x3d, 0x55, 0xa5, 0x03, +}; + +/* + * IV method encblkno8, blkno 2. + */ +static const uint8_t c3des_cbc_192_encblkno8_vec2_ctxt[SECSIZE] = { + 0xea, 0x7c, 0x8c, 0x8e, 0x3e, 0x61, 0x34, 0x3d, + 0xe0, 0x7f, 0xd3, 0xe1, 0x3a, 0xb9, 0xc8, 0xf2, + 0x98, 0xdc, 0x59, 0x26, 0xd2, 0xd8, 0xa7, 0x7f, + 0x41, 0x98, 0x24, 0xa8, 0x28, 0x0c, 0x88, 0x55, + 0x91, 0xdb, 0x29, 0x17, 0x70, 0xd7, 0x03, 0xff, + 0xbd, 0x0e, 0xbf, 0xf8, 0x73, 0x92, 0x19, 0xe9, + 0x92, 0x67, 0xdb, 0x08, 0x94, 0x77, 0x71, 0x2d, + 0x00, 0xad, 0x26, 0x42, 0x2d, 0xac, 0x8c, 0x67, + 0x6f, 0xb3, 0x8e, 0x36, 0x22, 0xeb, 0x1f, 0x8c, + 0xd4, 0x9b, 0x9f, 0xa6, 0xa9, 0xb1, 0x52, 0x65, + 0x9a, 0xfe, 0xcc, 0x92, 0x48, 0x75, 0xf6, 0xb8, + 0x59, 0xfe, 0x0e, 0x67, 0x93, 0xce, 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0xac, 0x96, 0xd0, 0x0f, 0x9b, 0x68, + 0x7d, 0x3f, 0xc2, 0xdd, 0x3d, 0xfc, 0xca, 0xcd, + 0x11, 0x71, 0xd9, 0x48, 0x53, 0x9f, 0xd3, 0x79, + 0x7d, 0x47, 0x71, 0x2a, 0x6d, 0x9e, 0xa9, 0x47, + 0xa1, 0xf7, 0x97, 0x80, 0x83, 0x70, 0x6b, 0xfe, + 0x10, 0x11, 0x6a, 0x0e, 0xdd, 0xde, 0x22, 0x3c, + 0x19, 0x30, 0x73, 0x73, 0x2e, 0x4b, 0x54, 0x17, + 0xc3, 0x2e, 0xe9, 0xce, 0xe0, 0xe3, 0xa0, 0x1a, + 0x28, 0xd1, 0x50, 0xa8, 0xd2, 0x40, 0xe2, 0x1b, + 0xfa, 0x49, 0x06, 0x49, 0x8b, 0x4b, 0xd9, 0xd5, + 0xf5, 0x50, 0xae, 0x64, 0x19, 0xe1, 0xd9, 0x4e, + 0xbb, 0x29, 0x70, 0x66, 0x46, 0xa8, 0x7e, 0x5b, + 0xdc, 0xe2, 0xd5, 0x9d, 0x56, 0x6d, 0x4c, 0xe6, + 0x0e, 0x6b, 0x71, 0x40, 0x82, 0xf7, 0xb3, 0xad, + 0x23, 0x17, 0xe3, 0x1c, 0x61, 0x1d, 0x3b, 0x71, + 0xfc, 0x06, 0x17, 0xec, 0x6c, 0x77, 0x98, 0x27, + 0xc7, 0x4b, 0x65, 0x17, 0x81, 0xe7, 0xcb, 0xce, + 0x09, 0x76, 0x82, 0x82, 0x4a, 0x53, 0x67, 0xa0, + 0x05, 0x25, 0x4c, 0xc4, 0xa7, 0xad, 0xa7, 0xaf, + 0xa0, 0x11, 0xd7, 0x73, 0x3b, 0x30, 0xbf, 0x53, + 0x50, 0x9b, 0xd8, 0xf3, 0x32, 0x15, 0xdd, 0x36, + 0x88, 0xc2, 0x39, 0x51, 0xb6, 0xb8, 0x0d, 0x5c, + 0x20, 0x4e, 0x24, 0xee, 0x95, 0x32, 0x61, 0x25, + 0xda, 0x73, 0x0d, 0x8a, 0x58, 0xe6, 0xcc, 0xad, + 0x79, 0x3d, 0xef, 0x29, 0x0c, 0x9f, 0xe1, 0xa7, + 0x22, 0x1e, 0xea, 0x7a, 0x4f, 0xfb, 0xc1, 0x1f, + 0x17, 0xca, 0x69, 0xd6, 0xa4, 0xce, 0x6e, 0xc0, + 0x70, 0xa3, 0x08, 0x32, 0x87, 0xb4, 0x6b, 0x80, + 0x5c, 0x7f, 0x88, 0x5c, 0xbf, 0x07, 0xd8, 0xe9, + 0xdd, 0xd2, 0x76, 0xa9, 0xaa, 0xd9, 0x55, 0x48, +}; + +/* + * IV method encblkno8, blkno 3. + */ +static const uint8_t c3des_cbc_192_encblkno8_vec3_ctxt[SECSIZE] = { + 0xf3, 0x49, 0xda, 0x5c, 0xde, 0x9d, 0x3e, 0x9d, + 0xb9, 0xc2, 0x6e, 0x96, 0xa9, 0x93, 0x10, 0x73, + 0x0e, 0x26, 0x39, 0xd6, 0x9f, 0x04, 0x5f, 0x69, + 0x54, 0xa3, 0x7c, 0x46, 0x7b, 0x18, 0x93, 0xc0, + 0xbb, 0x0c, 0x96, 0x6f, 0xb0, 0xbf, 0xce, 0x67, + 0x33, 0x3e, 0x56, 0xe8, 0x6b, 0x4d, 0x3f, 0xc8, + 0x3c, 0xc6, 0x89, 0x2c, 0x0b, 0x95, 0x3a, 0xaf, + 0xc0, 0xf3, 0x1f, 0x0e, 0x07, 0x01, 0xa6, 0x35, + 0x19, 0x79, 0x91, 0x24, 0xaa, 0x0d, 0xf0, 0x53, + 0x27, 0x7d, 0xbb, 0xa6, 0xb6, 0x44, 0x31, 0x4b, + 0xd4, 0xcf, 0xf6, 0x6d, 0x18, 0xa2, 0x28, 0x8a, + 0xc1, 0x0a, 0xbe, 0x57, 0x0c, 0x61, 0x5f, 0xd9, + 0x12, 0x14, 0xfe, 0xe2, 0xc7, 0x10, 0x72, 0xee, + 0x19, 0xb8, 0x16, 0x0b, 0x88, 0x87, 0xce, 0xf3, + 0xfe, 0x57, 0x37, 0xd1, 0xa2, 0xf7, 0xd0, 0x5e, + 0x73, 0xde, 0x39, 0x35, 0xbc, 0xde, 0xed, 0x61, + 0x4b, 0x31, 0xdc, 0xfe, 0x3c, 0x4d, 0x98, 0xa9, + 0x36, 0xb0, 0x34, 0x5b, 0xb4, 0xb7, 0x79, 0x25, + 0x6e, 0x24, 0x7e, 0x10, 0xfe, 0x20, 0xd5, 0x16, + 0x86, 0xaf, 0xcd, 0x26, 0x34, 0xd3, 0x2e, 0xdc, + 0x7c, 0x69, 0xe3, 0xc5, 0x62, 0x0c, 0xba, 0x29, + 0x9c, 0x4b, 0x2f, 0x39, 0x45, 0xe1, 0xcf, 0xc5, + 0xfe, 0x35, 0xb6, 0x2f, 0xb1, 0x1a, 0x90, 0xe1, + 0xa7, 0x39, 0xe8, 0x1e, 0x5f, 0xac, 0xab, 0x1e, + 0x32, 0xba, 0xc5, 0x92, 0x39, 0x62, 0x37, 0x2c, + 0x49, 0xf1, 0x62, 0x90, 0xf7, 0x1e, 0x10, 0xce, + 0x8e, 0x95, 0xa3, 0xc6, 0xd8, 0xe5, 0xc8, 0xdf, + 0xcc, 0x94, 0x7d, 0x26, 0xab, 0x29, 0xbb, 0x9d, + 0xf3, 0x73, 0xce, 0xac, 0x76, 0xdf, 0x75, 0x2a, + 0x3e, 0x8f, 0x47, 0xff, 0x76, 0xfe, 0xea, 0xd4, + 0x4a, 0xa9, 0x36, 0x9d, 0x12, 0x45, 0xb7, 0x99, + 0x81, 0xb6, 0x77, 0x98, 0x13, 0xfb, 0x5a, 0xe5, + 0x40, 0x87, 0x61, 0x0d, 0x10, 0x76, 0xf6, 0x3e, + 0x48, 0xac, 0xc4, 0x27, 0x87, 0xcd, 0x07, 0xde, + 0x0b, 0x23, 0x97, 0x61, 0x3d, 0x18, 0x64, 0x7f, + 0xbf, 0xd6, 0x87, 0xc1, 0x11, 0xfb, 0xf9, 0xda, + 0x14, 0xa1, 0x01, 0xf8, 0x7e, 0xea, 0x5b, 0x5b, + 0xdd, 0x09, 0xf9, 0x31, 0x80, 0x3c, 0xee, 0x34, + 0x2d, 0xda, 0x71, 0xd9, 0x32, 0x7d, 0x45, 0xb2, + 0x53, 0xea, 0xd5, 0x7c, 0x85, 0x45, 0xce, 0x1d, + 0x2b, 0xe9, 0xd7, 0x95, 0xf8, 0x8c, 0x08, 0xe4, + 0xd0, 0x2f, 0x60, 0x75, 0x02, 0xf3, 0xde, 0xeb, + 0x46, 0x40, 0xa8, 0xd2, 0x37, 0xd6, 0xca, 0x5d, + 0xb9, 0xf4, 0x51, 0x31, 0x8a, 0x1a, 0x82, 0xbd, + 0x6f, 0x6d, 0x88, 0x2b, 0x63, 0x0f, 0xe1, 0xf0, + 0xcf, 0x13, 0x79, 0x1d, 0x78, 0x82, 0x66, 0xa1, + 0xef, 0xdb, 0x34, 0x50, 0xd2, 0x71, 0x47, 0x49, + 0x41, 0x74, 0xd9, 0x0b, 0x14, 0x38, 0x1f, 0xc3, + 0x09, 0x4d, 0xb3, 0xa6, 0x03, 0x3f, 0x56, 0x67, + 0xd7, 0x51, 0x4c, 0x8a, 0x1d, 0x37, 0x99, 0xfb, + 0xe1, 0x84, 0x57, 0x55, 0x9b, 0xf8, 0x73, 0x63, + 0x68, 0x73, 0x89, 0x52, 0x06, 0xe7, 0x34, 0xe7, + 0x1a, 0x15, 0x7e, 0xd9, 0x84, 0xa3, 0x0e, 0x68, + 0x14, 0x1c, 0xe8, 0x23, 0x9e, 0xe3, 0x8f, 0x71, + 0x02, 0x9b, 0x87, 0xd4, 0xd9, 0x1b, 0xd1, 0x9e, + 0x9e, 0xa0, 0x7e, 0x49, 0x8e, 0xaa, 0x89, 0xb5, + 0x16, 0x48, 0x07, 0xb3, 0x3d, 0x9e, 0x4c, 0x35, + 0x3e, 0x94, 0xa9, 0xf8, 0x82, 0x50, 0x6a, 0x41, + 0x28, 0x3e, 0x9f, 0x9a, 0x1a, 0x5d, 0x02, 0x7c, + 0xd0, 0x32, 0x52, 0xa5, 0xee, 0x09, 0x27, 0x2d, + 0x49, 0x17, 0xf7, 0x92, 0xa1, 0x63, 0x9d, 0x2a, + 0xfd, 0x53, 0x26, 0x14, 0x7c, 0x92, 0x72, 0xa6, + 0x38, 0x18, 0x8f, 0xb5, 0x54, 0xb3, 0x69, 0x63, + 0x6a, 0xdc, 0xb1, 0x5a, 0x12, 0x7a, 0x0b, 0xa3, +}; + +const struct testvec c3des_cbc_192_8_vectors[] = { + { + .blkno = 0, + .ptxt = c3des_cbc_ptxt, + .ctxt = c3des_cbc_192_encblkno8_vec0_ctxt, + }, + { + .blkno = 1, + .ptxt = c3des_cbc_ptxt, + .ctxt = c3des_cbc_192_encblkno8_vec1_ctxt, + }, + { + .blkno = 2, + .ptxt = c3des_cbc_ptxt, + .ctxt = c3des_cbc_192_encblkno8_vec2_ctxt, + }, + { + .blkno = 3, + .ptxt = c3des_cbc_ptxt, + .ctxt = c3des_cbc_192_encblkno8_vec3_ctxt, + }, +}; + +static int +open_disk(const char *devpath, const char *imgpath, size_t size) +{ + int fd; + + fd = open(imgpath, O_CREAT | O_RDWR | O_TRUNC, 0600); + if (fd < 0) + return -1; + + if (ftruncate(fd, size) < 0) + goto fail; + + if (rump_pub_etfs_register_withsize(devpath, + imgpath, RUMP_ETFS_BLK, 0, size) < 0) { + goto fail; + } + + unlink(imgpath); + return fd; +fail: + close(fd); + unlink(imgpath); + return -1; +} + +static int +open_cgd(int devno) +{ + char devpath[32]; + + sprintf(devpath, "/dev/rcgd%d%c", devno, getrawpartition() + 'a'); + + return rump_sys_open(devpath, O_RDWR, 0); +} + +static int +configure_cgd(int fd, const char *dkpath, const char *alg, + const char *ivmethod, const char *key, size_t keylen) +{ + struct cgd_ioctl ci; + + memset(&ci, 0, sizeof(ci)); + ci.ci_disk = dkpath; + ci.ci_alg = alg; + ci.ci_ivmethod = ivmethod; + ci.ci_keylen = 8 * keylen - 8; /* Exclude the NUL terminator. */ + ci.ci_key = key; + ci.ci_blocksize = 64; + + return rump_sys_ioctl(fd, CGDIOCSET, &ci); +} + +static int +unconfigure_cgd(int fd) +{ + struct cgd_ioctl ci; + + return rump_sys_ioctl(fd, CGDIOCCLR, &ci); +} + +static int +write_testvec(int cgdfd, const struct testvec *tv) +{ + + if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0) + return -1; + + if (rump_sys_write(cgdfd, tv->ptxt, SECSIZE) != SECSIZE) + return -1; + + return 0; +} + +static int +read_testvec(int cgdfd, const struct testvec *tv) +{ + char *buf; + int res = -1; + + buf = malloc(SECSIZE); + if (buf == NULL) + return -1; + + if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0) + goto fail; + + if (rump_sys_read(cgdfd, buf, SECSIZE) != SECSIZE) + goto fail; + + res = memcmp(buf, tv->ptxt, SECSIZE); +fail: + free(buf); + return res; +} + +static int +check_testvec(int dkfd, const struct testvec *tv) +{ + char *buf; + int res = -1; + + buf = malloc(SECSIZE); + if (buf == NULL) + return -1; + + if (lseek(dkfd, tv->blkno * SECSIZE, SEEK_SET) < 0) + goto fail; + + if (read(dkfd, buf, SECSIZE) != SECSIZE) + goto fail; + + res = memcmp(buf, tv->ctxt, SECSIZE); +fail: + free(buf); + return res; +} + +ATF_TC(cgd_3des_cbc_192_encblkno1); +ATF_TC_HEAD(cgd_3des_cbc_192_encblkno1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test 3des-cbc with 192 bits key, ivmethod encblkno1"); +} + +ATF_TC_BODY(cgd_3des_cbc_192_encblkno1, tc) +{ + const char imgpath[] = "3des-cbc-192-encblkno1.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "3des-cbc", "encblkno1", + c3des_cbc_192_key, sizeof(c3des_cbc_192_key))); + + ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_1_vectors[0]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_1_vectors[1]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_1_vectors[2]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_1_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "3des-cbc", "encblkno1", + c3des_cbc_192_key, sizeof(c3des_cbc_192_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_1_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_1_vectors[1]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_1_vectors[2]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_1_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_1_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_1_vectors[1]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_1_vectors[2]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_1_vectors[3]), 0); + + RL(close(dkfd)); +} + +ATF_TC(cgd_3des_cbc_192_encblkno8); +ATF_TC_HEAD(cgd_3des_cbc_192_encblkno8, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test 3des-cbc with 192 bits key, ivmethod encblkno8"); +} + +ATF_TC_BODY(cgd_3des_cbc_192_encblkno8, tc) +{ + const char imgpath[] = "3des-cbc-192-encblkno8.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "3des-cbc", "encblkno8", + c3des_cbc_192_key, sizeof(c3des_cbc_192_key))); + + ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_8_vectors[0]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_8_vectors[1]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_8_vectors[2]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_8_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "3des-cbc", "encblkno8", + c3des_cbc_192_key, sizeof(c3des_cbc_192_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_8_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_8_vectors[1]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_8_vectors[2]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_8_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_8_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_8_vectors[1]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_8_vectors[2]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_8_vectors[3]), 0); + + RL(close(dkfd)); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, cgd_3des_cbc_192_encblkno1); + ATF_TP_ADD_TC(tp, cgd_3des_cbc_192_encblkno8); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/dev/cgd/t_cgd_aes.c b/contrib/netbsd-tests/dev/cgd/t_cgd_aes.c new file mode 100644 index 0000000..9416333 --- /dev/null +++ b/contrib/netbsd-tests/dev/cgd/t_cgd_aes.c @@ -0,0 +1,3606 @@ +/* $NetBSD: t_cgd_aes.c,v 1.5 2016/12/11 00:23:44 alnsn Exp $ */ +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * Copyright (c) 2007 The Institute of Electrical and Electronics Engineers, Inc + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Alexander Nasonov. + * + * 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 COPYRIGHT HOLDERS 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 + * COPYRIGHT HOLDERS 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. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "../../h_macros.h" + +#define SECSIZE 512 + +struct testvec { + unsigned int blkno; + const uint8_t *ptxt; /* PlainText */ + const uint8_t *ctxt; /* CipherText */ +}; + +/* + * 128 bits CBC key, NUL terminated. + */ +static const char aes_cbc_128_key[17] = { + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */ + 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, /* 89ABCDEF */ + 0 +}; + +/* + * 192 bits CBC key, NUL terminated. + */ +static const char aes_cbc_192_key[25] = { + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, /* ABCDEFGH */ + 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* IJKLMNOP */ + 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* QRSTUVWX */ + 0 +}; + +/* + * 256 bits CBC key, NUL terminated. + */ +static const char aes_cbc_256_key[33] = { + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */ + 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, /* 89ABCDEF */ + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */ + 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* 89abcdef */ + 0 +}; + +static const uint8_t aes_cbc_ptxt[SECSIZE] = + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop"; + +/* + * IV method encblkno1, blkno 0. + */ +static const uint8_t aes_cbc_128_encblkno1_vec0_ctxt[SECSIZE] = { + 0x1e, 0x95, 0x12, 0x15, 0xf6, 0xe0, 0xa7, 0x56, + 0x95, 0xa0, 0xa7, 0x35, 0x77, 0xf4, 0xdd, 0xdc, + 0x37, 0xc0, 0x28, 0x20, 0x00, 0x79, 0xa0, 0x35, + 0xe0, 0x83, 0x23, 0x95, 0x4e, 0xea, 0x8d, 0xa2, + 0x11, 0xbf, 0x9a, 0xd5, 0x21, 0x1e, 0x15, 0xb9, + 0xd1, 0x2e, 0xd2, 0xd9, 0xa5, 0xcc, 0x26, 0x75, + 0xba, 0x3e, 0x30, 0x11, 0xb2, 0x40, 0xdd, 0x1d, + 0x07, 0x3b, 0xe6, 0x00, 0xa7, 0x31, 0x9e, 0x58, + 0x41, 0xf3, 0x02, 0xf5, 0xad, 0x35, 0x79, 0x9a, + 0x9e, 0x03, 0xc8, 0x7a, 0x9d, 0x1d, 0x58, 0x9f, + 0x98, 0x67, 0xe2, 0x49, 0x81, 0x0c, 0x23, 0x90, + 0xd8, 0xc6, 0xf0, 0xc5, 0x73, 0x46, 0xd5, 0x14, + 0x1d, 0x78, 0x24, 0x7c, 0x9f, 0x5c, 0x8c, 0xe6, + 0x5d, 0x85, 0x7a, 0x5f, 0x76, 0xcc, 0xd8, 0xe9, + 0x03, 0xff, 0xfd, 0xd4, 0x12, 0x3f, 0xcb, 0xb0, + 0xfe, 0xfd, 0x86, 0x00, 0x0c, 0xe3, 0xdd, 0xa6, + 0x89, 0x92, 0xfe, 0xc8, 0x07, 0x5a, 0x94, 0x55, + 0x75, 0xae, 0x68, 0x47, 0xba, 0x84, 0x75, 0x58, + 0x33, 0x30, 0x2c, 0x16, 0x5b, 0xe9, 0x3f, 0x2a, + 0x09, 0xf9, 0x69, 0x23, 0x77, 0xd7, 0x2b, 0x95, + 0x4b, 0x78, 0x59, 0xcc, 0xfa, 0xf5, 0x79, 0xd2, + 0x05, 0x87, 0x66, 0x57, 0x93, 0xbf, 0x05, 0x90, + 0x4d, 0x6d, 0xd2, 0x72, 0x92, 0x24, 0xec, 0x14, + 0xe7, 0xbf, 0x82, 0x57, 0xbb, 0x14, 0x51, 0xe6, + 0xce, 0x3f, 0xa1, 0xfc, 0x63, 0x75, 0xee, 0xde, + 0xf9, 0x31, 0xd3, 0xa0, 0x07, 0xcd, 0x4d, 0x8f, + 0x83, 0x7d, 0x65, 0xe1, 0xc6, 0x60, 0x9e, 0x5c, + 0x51, 0x76, 0xfa, 0x64, 0xdf, 0xdc, 0xaf, 0x38, + 0xee, 0xe9, 0x8f, 0x4b, 0xa0, 0x3a, 0x21, 0xdf, + 0x58, 0x3b, 0x73, 0xf5, 0x30, 0xbb, 0x29, 0xe0, + 0xff, 0x60, 0xf0, 0x05, 0x5e, 0x37, 0xbc, 0x78, + 0x95, 0x3f, 0xa8, 0xd4, 0xb4, 0x82, 0x0d, 0xe1, + 0x10, 0xe3, 0xa7, 0x61, 0x37, 0x58, 0x28, 0x14, + 0x22, 0x57, 0x32, 0x28, 0x80, 0x98, 0x3e, 0x5f, + 0x71, 0xcf, 0x34, 0xb8, 0x6d, 0x6b, 0xc0, 0x23, + 0xc1, 0x9e, 0x58, 0x4f, 0xd5, 0xa4, 0x14, 0x03, + 0x2a, 0xed, 0xc4, 0xa7, 0x77, 0x7c, 0x4f, 0x94, + 0x91, 0x1d, 0x47, 0x34, 0x82, 0xe8, 0x9d, 0x32, + 0x5c, 0xc7, 0x38, 0xe9, 0x92, 0xcd, 0x35, 0xfd, + 0x1c, 0xcc, 0x3c, 0x28, 0x75, 0x6f, 0xff, 0xd5, + 0xe8, 0xbf, 0x90, 0x92, 0x34, 0x13, 0x11, 0x89, + 0xe0, 0xa2, 0x25, 0xeb, 0x82, 0x63, 0x31, 0x80, + 0x50, 0x6c, 0x99, 0xaa, 0x97, 0x0e, 0x59, 0x45, + 0x64, 0xb8, 0x77, 0x78, 0x6b, 0x24, 0xac, 0xc0, + 0xc9, 0xa9, 0xbc, 0x13, 0xd1, 0x5e, 0x50, 0x9a, + 0x91, 0x1a, 0x08, 0xf7, 0xc5, 0x18, 0x9f, 0x87, + 0x97, 0x9c, 0x0a, 0x27, 0xf1, 0x66, 0xf8, 0x09, + 0x52, 0x09, 0x41, 0x07, 0xc1, 0xa1, 0x91, 0xa4, + 0x59, 0x09, 0x75, 0x57, 0x5b, 0x53, 0x79, 0x58, + 0xa2, 0x9e, 0x49, 0xa2, 0x5e, 0xf7, 0x28, 0x1c, + 0x43, 0xa6, 0xcb, 0x88, 0x46, 0x84, 0xc9, 0x7f, + 0x84, 0xdb, 0x45, 0x0c, 0xb3, 0x7f, 0x01, 0x40, + 0x71, 0x3e, 0x48, 0x12, 0x1f, 0xbc, 0x1e, 0xdf, + 0x41, 0x50, 0xb2, 0x11, 0x67, 0x83, 0x19, 0x04, + 0x0e, 0x21, 0xd5, 0xf2, 0x54, 0x99, 0xfb, 0x47, + 0xf2, 0x5e, 0x02, 0x4b, 0x61, 0x6d, 0xef, 0x78, + 0x29, 0xe4, 0x3a, 0x56, 0x14, 0x20, 0x6f, 0x70, + 0x82, 0xea, 0x5d, 0xbc, 0x48, 0x89, 0x34, 0x69, + 0xdb, 0x4a, 0x06, 0xa7, 0xd6, 0xc7, 0xb7, 0x06, + 0x8e, 0x64, 0x21, 0x3e, 0xa6, 0x32, 0x61, 0x59, + 0x03, 0xea, 0xc3, 0x71, 0xf0, 0x26, 0x02, 0xe0, + 0x71, 0x95, 0x38, 0x11, 0x32, 0xe6, 0x3b, 0x25, + 0x53, 0x14, 0x24, 0x34, 0xe8, 0x8c, 0xa8, 0xef, + 0x52, 0xfe, 0x06, 0x2c, 0x20, 0x88, 0x4f, 0xa6, +}; + +/* + * IV method encblkno1, blkno 1. + */ +static const uint8_t aes_cbc_128_encblkno1_vec1_ctxt[SECSIZE] = { + 0x2f, 0x69, 0x3e, 0x95, 0x87, 0x91, 0x99, 0xd4, + 0xd9, 0x5d, 0xf2, 0x52, 0x32, 0x54, 0x2a, 0x80, + 0xa0, 0x77, 0x6e, 0x73, 0x15, 0xb4, 0xc9, 0x13, + 0x85, 0xed, 0x79, 0x9b, 0x84, 0x0a, 0x7e, 0xdb, + 0xee, 0x09, 0x78, 0x11, 0x28, 0xd5, 0x26, 0xec, + 0x1d, 0x52, 0xba, 0x33, 0x26, 0xeb, 0x91, 0xc6, + 0x4b, 0xf0, 0x38, 0xdf, 0x9f, 0x9d, 0x6c, 0xd8, + 0x49, 0x83, 0x88, 0xbe, 0x62, 0x2d, 0x5e, 0x88, + 0xc0, 0x35, 0xe4, 0xc3, 0xc9, 0x9f, 0x62, 0x59, + 0x16, 0xa7, 0x2e, 0xc0, 0xda, 0x3c, 0x2e, 0x10, + 0x53, 0xf0, 0x84, 0x27, 0x38, 0xd0, 0xf4, 0xb5, + 0x7c, 0x4a, 0x63, 0x04, 0x51, 0x22, 0xae, 0xf3, + 0xe7, 0x97, 0x53, 0xee, 0xe6, 0xaf, 0xc3, 0x49, + 0x3a, 0x5a, 0x74, 0x83, 0x18, 0xa3, 0x6b, 0xf3, + 0x6a, 0x3b, 0xe2, 0x1b, 0xd4, 0x64, 0x41, 0xdf, + 0xd1, 0xd2, 0xdd, 0x22, 0xa8, 0x66, 0xbd, 0x8e, + 0xc4, 0x9a, 0x6d, 0x15, 0x38, 0x5b, 0x50, 0x9a, + 0x65, 0x48, 0x97, 0xf1, 0x04, 0x85, 0x8b, 0x5c, + 0x44, 0x32, 0x15, 0xea, 0x28, 0x5f, 0x98, 0x53, + 0xb4, 0x80, 0xd0, 0x2c, 0x59, 0x04, 0x08, 0xaf, + 0xa4, 0xb7, 0x49, 0xd1, 0x98, 0x87, 0xb9, 0xb6, + 0x3d, 0x89, 0xd1, 0xbe, 0xf4, 0x89, 0xec, 0xf9, + 0x2d, 0xc7, 0xc6, 0xe9, 0xe6, 0xfa, 0x1e, 0x67, + 0x68, 0xe7, 0xb7, 0x91, 0x55, 0x77, 0xf3, 0x27, + 0x38, 0x23, 0xcf, 0x2e, 0x3e, 0x8b, 0xfd, 0xb3, + 0x90, 0xd8, 0x6b, 0x1e, 0x93, 0x8f, 0xb6, 0xc1, + 0x27, 0xc2, 0xb7, 0x76, 0x10, 0x69, 0xe8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, 0x95, 0xe8, 0x09, 0x3d, 0x4d, 0xdf, + 0xd9, 0xc0, 0x63, 0x17, 0xa5, 0x9c, 0xf6, 0xa3, + 0x59, 0x17, 0xc0, 0xf8, 0xa2, 0x11, 0x14, 0x88, + 0xf0, 0x1e, 0x4a, 0x4b, 0x13, 0xf6, 0xd6, 0x09, + 0xac, 0xf8, 0x39, 0x5d, 0x4c, 0x68, 0x69, 0x99, + 0x08, 0xd4, 0xf5, 0x39, 0x6d, 0x78, 0xde, 0xb5, + 0x6f, 0x34, 0xc4, 0x28, 0x73, 0x6c, 0x29, 0xa1, + 0xef, 0xfe, 0xed, 0x56, 0xb2, 0x70, 0x7b, 0xd5, + 0x5b, 0xd1, 0x09, 0x6a, 0x9a, 0x59, 0xe9, 0x79, + 0xe9, 0xee, 0xa4, 0x03, 0xc1, 0x67, 0xce, 0x62, + 0xf6, 0x4f, 0x04, 0xa5, 0x04, 0x71, 0x13, 0xeb, + 0x3d, 0x0a, 0x65, 0x2f, 0x57, 0xb0, 0xc0, 0xa4, + 0xf2, 0x8d, 0x78, 0x90, 0xeb, 0xc9, 0x5e, 0x8b, + 0xd8, 0xfb, 0xbc, 0x74, 0x1a, 0x70, 0x94, 0x2c, + 0xeb, 0xf2, 0x5e, 0x6d, 0xbb, 0x96, 0x7a, 0x2c, +}; + +/* + * IV method encblkno1, blkno 2. + */ +static const uint8_t aes_cbc_128_encblkno1_vec2_ctxt[SECSIZE] = { + 0xbc, 0x49, 0x35, 0x2c, 0xe3, 0x10, 0x12, 0x65, + 0x7a, 0xf4, 0xde, 0xd3, 0xf8, 0xe1, 0x49, 0x97, + 0x0a, 0x07, 0x93, 0x6c, 0xf8, 0x0e, 0xb7, 0xdf, + 0x53, 0xba, 0x1e, 0x8e, 0x14, 0xbd, 0xf6, 0x81, + 0xd6, 0xf6, 0x3d, 0xb2, 0xe7, 0x6a, 0x9d, 0x50, + 0x68, 0xc2, 0x75, 0x8e, 0xfb, 0x44, 0xfa, 0xc8, + 0x9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2, 0xd6, 0x90, 0x70, 0x5e, + 0xf5, 0x58, 0x70, 0xe0, 0xff, 0x5a, 0xf5, 0xee, + 0x32, 0x4f, 0x61, 0x1c, 0xf6, 0xbf, 0xd5, 0x7c, + 0x73, 0xb9, 0x1d, 0x30, 0xc2, 0xfb, 0x2f, 0x9a, + 0xf7, 0x57, 0x2e, 0x87, 0x7d, 0xcb, 0xdd, 0x7e, + 0xda, 0xec, 0x47, 0x1a, 0x0e, 0x70, 0x2d, 0x6e, + 0x18, 0x2b, 0x89, 0xc1, 0x85, 0x58, 0x6d, 0x4b, + 0x45, 0x11, 0xcf, 0x82, 0x9f, 0x31, 0xd0, 0x42, + 0x11, 0xca, 0xa8, 0x52, 0x66, 0xf7, 0xf1, 0x1d, + 0x86, 0xe3, 0xb4, 0x41, 0xcb, 0x92, 0xb1, 0x9f, + 0x8d, 0x8e, 0x08, 0xe9, 0xc4, 0x66, 0xce, 0x9d, + 0xae, 0x91, 0xaf, 0xe6, 0xa6, 0x2e, 0x06, 0x3a, + 0xf5, 0x27, 0x48, 0xe4, 0x31, 0x0f, 0xc5, 0xdf, + 0x29, 0x56, 0xed, 0x62, 0xf3, 0xef, 0xca, 0xa6, + 0x58, 0xd1, 0x84, 0x99, 0xd3, 0x34, 0x67, 0x92, + 0x6a, 0xb2, 0xd1, 0xd1, 0x50, 0x1f, 0xe9, 0xd8, + 0x3c, 0xbe, 0x12, 0x97, 0x7c, 0x4f, 0xc0, 0xbe, + 0x91, 0x32, 0x15, 0xd5, 0xf2, 0x5e, 0xe6, 0x13, + 0x86, 0xfa, 0xc6, 0xde, 0xd8, 0xe1, 0x70, 0xb4, + 0xf7, 0x5b, 0x9f, 0x79, 0x55, 0x22, 0x7a, 0xe1, + 0x54, 0x40, 0x39, 0x11, 0xe1, 0x78, 0x01, 0x01, + 0xc0, 0x44, 0xeb, 0x92, 0xb9, 0x01, 0xdd, 0x56, + 0xb9, 0x7e, 0xa0, 0x50, 0x41, 0x58, 0xb2, 0x13, + 0x12, 0x44, 0xd2, 0x39, 0xf2, 0x76, 0x3c, 0x53, + 0x36, 0xfe, 0x17, 0x74, 0x91, 0x8d, 0xbe, 0xc5, + 0x40, 0xf7, 0xa2, 0xe9, 0x65, 0xd9, 0xdf, 0x80, + 0x7b, 0xd9, 0xc3, 0x1f, 0xb4, 0xfc, 0x9f, 0x8d, + 0x7a, 0x4e, 0x1e, 0x32, 0x6d, 0xb1, 0x82, 0x1e, + 0x0c, 0xb6, 0x0b, 0xe6, 0x15, 0x82, 0x5c, 0xcc, + 0xc8, 0x4a, 0x73, 0x56, 0x9d, 0x11, 0xfa, 0xcd, + 0x21, 0x95, 0x23, 0x71, 0xe8, 0xfe, 0x06, 0x43, + 0xf6, 0x17, 0x51, 0x28, 0x0d, 0xfb, 0x0a, 0x49, + 0x1b, 0x35, 0x1e, 0x4a, 0x38, 0x08, 0x6b, 0xcd, + 0x67, 0x21, 0x94, 0x09, 0x28, 0xca, 0x0a, 0x18, + 0xdf, 0x6c, 0x86, 0x47, 0x10, 0x29, 0x81, 0x9a, + 0x73, 0xba, 0x78, 0xbd, 0xc0, 0x61, 0xee, 0x23, +}; + +/* + * IV method encblkno1, blkno 3. + */ +static const uint8_t aes_cbc_128_encblkno1_vec3_ctxt[SECSIZE] = { + 0x29, 0x9f, 0xb1, 0x0f, 0x7d, 0xb4, 0xd9, 0xbb, + 0xf9, 0x06, 0x60, 0xdc, 0xb9, 0xeb, 0x73, 0x6e, + 0xfe, 0xdb, 0x99, 0x29, 0xe8, 0x42, 0x46, 0xe7, + 0x49, 0xcf, 0x90, 0x2d, 0x08, 0xd7, 0xd5, 0xbf, + 0x0f, 0x4f, 0x66, 0xce, 0xcd, 0xb1, 0x8a, 0xc7, + 0x47, 0xc9, 0x8e, 0xe3, 0x9f, 0x80, 0x79, 0xc6, + 0xa8, 0xe5, 0x20, 0x66, 0x58, 0xde, 0xab, 0x87, + 0x5e, 0x7e, 0xcd, 0x55, 0x81, 0x09, 0x40, 0xd9, + 0x8b, 0x7e, 0xd3, 0xf9, 0x16, 0x55, 0x72, 0x7d, + 0xe8, 0x36, 0x76, 0x06, 0x77, 0x47, 0xa5, 0xdc, + 0x80, 0x33, 0x7d, 0x88, 0x5f, 0x56, 0x48, 0x0f, + 0x66, 0xb5, 0x91, 0x9d, 0xf8, 0xdb, 0x83, 0x0d, + 0xd4, 0xc6, 0x13, 0xfc, 0xd4, 0xe5, 0x34, 0x81, + 0x70, 0x4d, 0x96, 0x82, 0x5d, 0xb2, 0x36, 0x37, + 0xdf, 0xd2, 0x5e, 0x31, 0xf0, 0x9d, 0x6d, 0xb7, + 0xf9, 0x2d, 0xcb, 0x77, 0xb8, 0x59, 0xa0, 0xbb, + 0x4f, 0x8d, 0xa0, 0xd1, 0x49, 0x17, 0x93, 0x3c, + 0xf0, 0x4e, 0x72, 0xdd, 0x99, 0x9a, 0x87, 0xf1, + 0x01, 0x89, 0xdf, 0xef, 0xed, 0x04, 0x86, 0x3d, + 0x9b, 0xab, 0x6c, 0xa7, 0xef, 0x1b, 0xbb, 0x24, + 0xbc, 0x65, 0x01, 0x06, 0x12, 0x3f, 0x7e, 0x9f, + 0x83, 0xf3, 0xd4, 0x43, 0x18, 0x03, 0xa3, 0x07, + 0xbc, 0x85, 0xe8, 0xdb, 0x6c, 0x8f, 0xaf, 0x70, + 0x71, 0x5d, 0xbc, 0x6d, 0x14, 0x05, 0xdf, 0xce, + 0x9f, 0xe2, 0xa3, 0x51, 0x66, 0x92, 0x52, 0x19, + 0x98, 0xbd, 0xb2, 0x68, 0x79, 0xf4, 0x5d, 0x71, + 0xcb, 0xa0, 0x1b, 0x77, 0x34, 0x46, 0x69, 0x3c, + 0xa4, 0x0f, 0x72, 0xf5, 0x73, 0xf6, 0xa0, 0xe9, + 0x72, 0xef, 0xa1, 0xcc, 0x43, 0xfc, 0xb7, 0xf3, + 0x59, 0xeb, 0x40, 0x61, 0x02, 0x26, 0x9b, 0x71, + 0x57, 0x17, 0x36, 0xac, 0xc8, 0xd5, 0x9d, 0xcb, + 0x4d, 0x4f, 0xf7, 0xc1, 0x58, 0xce, 0xbf, 0x73, + 0xe7, 0xd0, 0x58, 0x0d, 0x08, 0x01, 0x8f, 0x68, + 0x1b, 0x3f, 0x3a, 0x7b, 0xdb, 0x9e, 0xa7, 0x33, + 0x59, 0x91, 0xa8, 0xe3, 0x58, 0x22, 0x3f, 0x97, + 0xe1, 0xdb, 0xd6, 0x99, 0x0e, 0xdd, 0x76, 0xcd, + 0x4d, 0x02, 0x28, 0x43, 0x8a, 0xdd, 0x10, 0xad, + 0x55, 0xe0, 0x62, 0xf7, 0x44, 0xbc, 0x3f, 0x99, + 0x3c, 0x09, 0x25, 0xfb, 0xfd, 0x1e, 0x4c, 0x45, + 0x0e, 0x6e, 0x75, 0x15, 0x48, 0x19, 0x08, 0xc3, + 0x2b, 0x81, 0x60, 0x5f, 0x19, 0x09, 0x74, 0x0a, + 0xbd, 0x0d, 0x8d, 0x94, 0x55, 0x04, 0x2b, 0x8e, + 0x0d, 0x10, 0x60, 0x64, 0x0d, 0x7f, 0x63, 0x2e, + 0x89, 0x0b, 0xfc, 0x1c, 0xbc, 0xf3, 0x66, 0xc5, + 0x80, 0x93, 0x3a, 0x74, 0x15, 0x11, 0xd5, 0xba, + 0xbc, 0x06, 0x3f, 0x85, 0xcc, 0x6c, 0xd3, 0xf2, + 0x74, 0xc6, 0x10, 0x15, 0x0a, 0x02, 0x66, 0xa4, + 0xa8, 0x93, 0x0b, 0x5c, 0xe7, 0x13, 0x96, 0x90, + 0xdd, 0xe3, 0x25, 0x22, 0x46, 0x7b, 0x49, 0xde, + 0x72, 0x55, 0xf3, 0x30, 0x62, 0x5f, 0x7a, 0x2a, + 0x37, 0x88, 0xea, 0x57, 0x99, 0x64, 0x50, 0x2d, + 0xd3, 0x6a, 0x09, 0x4b, 0xd6, 0x61, 0xf2, 0x22, + 0x53, 0x36, 0xf7, 0x42, 0x21, 0xde, 0xda, 0xcb, + 0x8b, 0x6f, 0xf3, 0x4e, 0x2c, 0x16, 0xfb, 0xfc, + 0x13, 0xa7, 0xd1, 0xd8, 0xfd, 0x16, 0x39, 0x20, + 0xe0, 0xb2, 0xb4, 0xd5, 0x40, 0x93, 0x30, 0xf3, + 0xab, 0x88, 0xe3, 0xfb, 0xbe, 0xb8, 0x02, 0x3a, + 0x78, 0x2d, 0x56, 0x4b, 0x92, 0x5b, 0x0a, 0x8d, + 0x18, 0xa4, 0x5b, 0x11, 0x60, 0x0b, 0x45, 0xad, + 0x0b, 0x64, 0x96, 0x7d, 0x84, 0xf2, 0x20, 0xa8, + 0x95, 0x78, 0xb3, 0xb5, 0x98, 0x1f, 0xa7, 0x3e, + 0x30, 0x77, 0x43, 0xd2, 0x8c, 0x20, 0xc5, 0x5e, + 0x76, 0xcd, 0x2c, 0x7c, 0xfa, 0x34, 0x36, 0xda, + 0x39, 0x00, 0x2e, 0x69, 0x4a, 0xb3, 0x0f, 0x6f, +}; + +const struct testvec aes_cbc_128_1_vectors[] = { + { + .blkno = 0, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_128_encblkno1_vec0_ctxt, + }, + { + .blkno = 1, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_128_encblkno1_vec1_ctxt, + }, + { + .blkno = 2, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_128_encblkno1_vec2_ctxt, + }, + { + .blkno = 3, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_128_encblkno1_vec3_ctxt, + }, +}; + +/* + * IV method encblkno8, blkno 0. + */ +static const uint8_t aes_cbc_128_encblkno8_vec0_ctxt[SECSIZE] = { + 0xa6, 0x64, 0xef, 0x0f, 0xc4, 0x45, 0xcc, 0x5e, + 0xf8, 0x27, 0x42, 0x5e, 0xbd, 0x93, 0x99, 0xcd, + 0x79, 0xa8, 0x7d, 0x72, 0xc4, 0x02, 0x99, 0xa6, + 0xe4, 0x69, 0x57, 0x82, 0xdf, 0x32, 0x4e, 0x67, + 0x2a, 0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0x5b, 0x85, 0x92, 0x94, 0xa8, 0x8f, 0x2c, 0x3a, + 0x7e, 0x22, 0x86, 0x88, 0x51, 0x03, 0xee, 0xf9, + 0x2e, 0x83, 0xce, 0x39, 0x0c, 0x76, 0x64, 0xe5, + 0x5a, 0x88, 0xef, 0xc5, 0x06, 0xb2, 0xe4, 0x13, + 0x82, 0xc9, 0xee, 0xba, 0x6d, 0x56, 0xa8, 0x87, + 0x51, 0x69, 0x3b, 0x86, 0x29, 0x8e, 0xe8, 0xb4, + 0x44, 0x42, 0x07, 0x5b, 0xff, 0x0e, 0x1e, 0x9f, + 0x42, 0xb1, 0xc8, 0x5f, 0xab, 0x3b, 0xc7, 0xba, + 0x75, 0x20, 0xe6, 0x9f, 0x93, 0xb5, 0xcf, 0x8f, + 0x7c, 0x1c, 0xf3, 0xdb, 0x6a, 0xf4, 0xde, 0x00, + 0xe9, 0xaf, 0xd5, 0xf4, 0x36, 0x98, 0x14, 0x2d, + 0x53, 0x20, 0x74, 0xab, 0x0c, 0xf6, 0xcd, 0x15, + 0x32, 0xa6, 0x01, 0x8d, 0x24, 0x1b, 0x4b, 0x1f, + 0xa3, 0xfc, 0x38, 0x82, 0x3a, 0xa1, 0xb5, 0x52, + 0x53, 0xc7, 0x2b, 0x30, 0x7c, 0x65, 0xb9, 0x7d, +}; + +/* + * IV method encblkno8, blkno 1. + */ +static const uint8_t aes_cbc_128_encblkno8_vec1_ctxt[SECSIZE] = { + 0x63, 0x45, 0x16, 0x0c, 0xe4, 0x4f, 0x51, 0xde, + 0x74, 0xf8, 0x7b, 0xf5, 0x05, 0x17, 0x13, 0x1e, + 0xa5, 0x3d, 0x84, 0xfa, 0x35, 0x5a, 0x2d, 0x3c, + 0xb7, 0x61, 0x68, 0xff, 0xcd, 0x33, 0x1f, 0x0b, + 0x53, 0x79, 0xf2, 0x2f, 0xbc, 0x8d, 0xac, 0xb9, + 0xf9, 0xb7, 0x9c, 0x0a, 0x9d, 0xa1, 0x4d, 0x78, + 0x9e, 0x4e, 0xfa, 0xe8, 0xc8, 0x46, 0x4b, 0x99, + 0x91, 0x7e, 0x33, 0x6e, 0x18, 0x24, 0x01, 0xc3, + 0x9f, 0x8c, 0x43, 0xb5, 0x15, 0x7e, 0xdd, 0xf9, + 0x1b, 0xb0, 0xf2, 0xc3, 0x97, 0x1f, 0x7c, 0x3f, + 0x43, 0x4c, 0x9f, 0x93, 0x29, 0x83, 0x8f, 0xad, + 0xd1, 0x5e, 0x92, 0x1a, 0x17, 0xd1, 0xa0, 0x05, + 0x6e, 0x62, 0x59, 0x80, 0x50, 0x6d, 0xe3, 0x28, + 0x9a, 0x43, 0xdc, 0x81, 0x4f, 0x49, 0xc4, 0x98, + 0xcd, 0x6d, 0x28, 0xb4, 0x86, 0xe4, 0x83, 0x45, + 0xd4, 0x43, 0x52, 0x8a, 0xd6, 0xc8, 0x1c, 0x90, + 0xeb, 0xf0, 0xe7, 0x76, 0xb4, 0x43, 0x9b, 0x56, + 0x48, 0x73, 0xdd, 0x01, 0x50, 0x1c, 0x61, 0xfc, + 0x22, 0xac, 0xf4, 0x27, 0x94, 0x02, 0x54, 0xd3, + 0x7d, 0x25, 0xf6, 0x14, 0x29, 0xbb, 0x2b, 0x22, + 0xc8, 0xe8, 0x7f, 0xa1, 0xfe, 0x19, 0x79, 0x97, + 0xb6, 0xa6, 0xba, 0x5b, 0x89, 0xdf, 0x73, 0x6d, + 0x79, 0x38, 0x5b, 0xf8, 0x89, 0xa2, 0x95, 0x1d, + 0xda, 0x38, 0x17, 0x4b, 0x01, 0xf1, 0x7d, 0x0a, + 0xa2, 0x8f, 0x5a, 0x02, 0x51, 0xb0, 0x88, 0x10, + 0x16, 0xc8, 0x82, 0xb9, 0x06, 0x9f, 0x01, 0x94, + 0xf9, 0xe0, 0x2e, 0x86, 0x8a, 0xb1, 0x7f, 0x74, + 0x22, 0xce, 0xee, 0xa6, 0x66, 0xee, 0xe2, 0x1d, + 0x98, 0x1b, 0x46, 0x22, 0x7e, 0x89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 0x5b, 0x60, 0x2f, 0xb5, 0xfe, 0x82, 0xaf, + 0x85, 0xb7, 0x79, 0x7c, 0xee, 0xad, 0xea, 0xfa, + 0x9b, 0xad, 0xca, 0x38, 0x21, 0x3d, 0x46, 0x8a, + 0x5b, 0xa7, 0x55, 0x3d, 0x88, 0x4a, 0x52, 0xdb, + 0xf2, 0x07, 0xed, 0xd6, 0x3c, 0x9f, 0x1b, 0x42, + 0xb4, 0x14, 0x12, 0xb7, 0x00, 0xfc, 0x6a, 0x79, + 0x61, 0x0b, 0x43, 0xaa, 0x44, 0x48, 0x30, 0x15, + 0x48, 0x76, 0x27, 0x32, 0x7a, 0x2e, 0x25, 0x6a, + 0x8c, 0x8c, 0x64, 0x67, 0x86, 0x54, 0x4a, 0x93, + 0x14, 0xfe, 0x81, 0xf5, 0xcf, 0x98, 0x92, 0xd3, + 0x92, 0xf5, 0x6a, 0x74, 0x28, 0x10, 0x6b, 0xd4, + 0x1d, 0x64, 0x7e, 0x05, 0x32, 0xba, 0xf7, 0x4c, + 0xe9, 0xa8, 0xa9, 0xc5, 0x35, 0x34, 0x26, 0x41, +}; + +/* + * IV method encblkno8, blkno 2. + */ +static const uint8_t aes_cbc_128_encblkno8_vec2_ctxt[SECSIZE] = { + 0x64, 0x7b, 0x62, 0x7a, 0xa6, 0xa9, 0xb3, 0x47, + 0xbc, 0x03, 0x14, 0x3d, 0x9b, 0x56, 0xfc, 0x13, + 0x08, 0x32, 0x81, 0xe3, 0x57, 0x3c, 0x0d, 0xbb, + 0x85, 0x44, 0x47, 0x12, 0xc4, 0x80, 0x35, 0x37, + 0xe1, 0xb4, 0x3f, 0x35, 0x98, 0x7c, 0xb0, 0x3b, + 0x85, 0xab, 0x3d, 0x0b, 0xd3, 0x6f, 0xf9, 0x92, + 0x00, 0x6b, 0x18, 0xe7, 0x31, 0x8b, 0x77, 0x4c, + 0xd0, 0x7b, 0x1d, 0xfc, 0x95, 0xe6, 0x02, 0x01, + 0x9c, 0x17, 0x4d,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x0c, 0xe8, + 0xdc, 0x12, 0x78, 0x4c, 0x52, 0xf4, 0xfc, 0x4a, + 0x77, 0xdd, 0x77, 0x34, 0xf7, 0x35, 0x94, 0x7a, + 0x31, 0x16, 0x86, 0x44, 0x50, 0x30, 0x1c, 0x6d, + 0x9f, 0x66, 0x49, 0xb5, 0xe6, 0x71, 0x00, 0x83, + 0xd1, 0xa0, 0x01, 0xff, 0xc3, 0x27, 0xaa, 0x9a, + 0xdb, 0xad, 0x24, 0xdb, 0xbd, 0xde, 0xfd, 0xa6, + 0xaa, 0x87, 0x98, 0x98, 0xde, 0x90, 0xd5, 0x40, + 0x20, 0x8f, 0xe9, 0xdd, 0xa8, 0xec, 0xd3, 0x18, + 0x20, 0x85, 0x5e, 0xd5, 0xe7, 0x50, 0x58, 0x15, + 0x69, 0x03, 0xa5, 0xe8, 0xa9, 0x7a, 0x0f, 0xd1, + 0x7d, 0x22, 0x8a, 0xe0, 0xc6, 0x17, 0x33, 0x00, + 0x57, 0xcb, 0xf6, 0x8d, 0xf0, 0xc1, 0x7b, 0xb5, + 0x96, 0x0f, 0x08, 0x84, 0x5b, 0x7e, 0xa6, 0x1e, + 0xd8, 0x5e, 0x0c, 0xca, 0x30, 0x4b, 0xe0, 0x87, + 0x2f, 0xbc, 0x07, 0x83, 0x35, 0x76, 0x36, 0x17, + 0xcf, 0xdb, 0x27, 0x53, 0x43, 0xf5, 0x07, 0xd0, + 0x91, 0x83, 0xa1, 0xaa, 0x8d, 0xdb, 0x00, 0x2b, + 0xd1, 0x88, 0xe5, 0x59, 0x47, 0x17, 0xf0, 0xe8, + 0xce, 0x3b, 0xa0, 0x73, 0x1f, 0x22, 0x9b, 0x1b, + 0x59, 0x02, 0xe6, 0xaf, 0x3f, 0xdd, 0xfe, 0xba, + 0xc3, 0x6b, 0xe5, 0x82, 0x02, 0x92, 0x0c, 0x5e, + 0x5a, 0x87, 0x88, 0x91, 0x00, 0xb5, 0x30, 0x37, + 0xf5, 0xc6, 0xdf, 0x0a, 0x7f, 0x03, 0x1c, 0x1f, + 0x20, 0xf1, 0xd4, 0x5f, 0x94, 0xc3, 0x6f, 0x21, + 0x5e, 0xf2, 0x77, 0x5a, 0x42, 0xfd, 0xd3, 0xc4, + 0x31, 0xaf, 0xd6, 0x6c, 0x6c, 0xde, 0x8c, 0x50, + 0x01, 0x8f, 0x57, 0x90, 0x88, 0x43, 0xf9, 0x44, + 0x09, 0x4d, 0x27, 0x58, 0x9f, 0xae, 0x50, 0x28, + 0x12, 0x47, 0x20, 0x79, 0x2b, 0xe4, 0x02, 0x97, + 0xcd, 0xab, 0x53, 0x28, 0x8f, 0x8f, 0xe3, 0x3b, + 0xd6, 0xc9, 0xc8, 0xff, 0xbf, 0x18, 0x3b, 0x75, + 0xdb, 0xcf, 0x07, 0x8c, 0xfe, 0x58, 0xee, 0x75, + 0x01, 0x98, 0x98, 0xe4, 0x60, 0xfe, 0xe6, 0x7f, +}; + +/* + * IV method encblkno8, blkno 3. + */ +static const uint8_t aes_cbc_128_encblkno8_vec3_ctxt[SECSIZE] = { + 0x98, 0xae, 0x82, 0x1d, 0x76, 0x3a, 0xfe, 0x80, + 0x04, 0xa3, 0x43, 0xf0, 0x06, 0x45, 0x83, 0xb7, + 0xe2, 0xb5, 0x73, 0x46, 0x78, 0x01, 0x2f, 0xd6, + 0x0d, 0x49, 0x64, 0x4c, 0xeb, 0x8d, 0xdc, 0xa9, + 0xdc, 0xea, 0x22, 0x25, 0xd4, 0x8f, 0xba, 0x9f, + 0xd4, 0x7a, 0x3c, 0x9e, 0xd0, 0xd9, 0xcd, 0xa4, + 0x12, 0xdf, 0x8f, 0x50, 0x24, 0x18, 0xa2, 0x0b, + 0xd9, 0x7f, 0xda, 0x78, 0xd6, 0x11, 0xf3, 0x99, + 0xc4, 0xec, 0x95, 0xe2, 0x85, 0xe1, 0xa0, 0x0d, + 0x07, 0x22, 0x56, 0xaf, 0x2f, 0xf5, 0x7d, 0x63, + 0xf2, 0x90, 0x6c, 0x26,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, 0xa5, 0xb3, 0x9b, 0x8d, 0x46, 0xb9, 0xf5, + 0x4a, 0x4d, 0xbe, 0xc0, 0xc1, 0x24, 0x92, 0x09, + 0x7c, 0x9a, 0x21, 0x2c, 0x08, 0x8a, 0x0d, 0xfc, + 0xff, 0xda, 0xdc, 0xf1, 0x45, 0x66, 0xf9, 0xcd, + 0x64, 0x7c, 0x2f, 0x0e, 0x95, 0x5e, 0xec, 0x92, + 0xd1, 0x03, 0x03, 0xa0, 0xcc, 0x73, 0x92, 0x15, + 0x74, 0x42, 0x54, 0x48, 0x77, 0xbe, 0x96, 0xfb, + 0x1f, 0x0c, 0x7a, 0x25, 0x67, 0x6b, 0x85, 0x71, + 0x06, 0x15, 0xd3, 0x11, 0xfe, 0xf7, 0xa9, 0xb1, +}; + +const struct testvec aes_cbc_128_8_vectors[] = { + { + .blkno = 0, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_128_encblkno8_vec0_ctxt, + }, + { + .blkno = 1, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_128_encblkno8_vec1_ctxt, + }, + { + .blkno = 2, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_128_encblkno8_vec2_ctxt, + }, + { + .blkno = 3, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_128_encblkno8_vec3_ctxt, + }, +}; + +/* + * IV method encblkno1, blkno 0. + */ +static const uint8_t aes_cbc_192_encblkno1_vec0_ctxt[SECSIZE] = { + 0x7c, 0xc4, 0xec, 0x89, 0x7c, 0x13, 0xac, 0x99, + 0x49, 0xa9, 0x96, 0xe7, 0xb1, 0x1a, 0xd6, 0xb0, + 0xeb, 0x89, 0x27, 0x0f, 0x8b, 0x1b, 0xab, 0x8e, + 0x2c, 0xd4, 0x00, 0x66, 0x12, 0x3a, 0x9a, 0x03, + 0xc4, 0x49, 0xa4, 0xf0, 0xc1, 0x90, 0xf9, 0x38, + 0xb2, 0x5c, 0xa5, 0x0d, 0x1b, 0x60, 0x94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0e, 0x82, 0x5f, 0x81, 0xba, 0x5d, + 0x79, 0x8f, 0x9c, 0x17, 0x4b, 0x59, 0xf4, 0x5d, + 0xd6, 0x83, 0xfd, 0x44, 0xd0, 0xe1, 0x89, 0x09, + 0xf9, 0xe2, 0xb6, 0x9c, 0x1c, 0xbd, 0x13, 0xaa, + 0xa0, 0x43, 0xaa, 0xaf, 0x6d, 0x65, 0x73, 0xba, + 0x3a, 0x55, 0x69, 0x51, 0xb9, 0x52, 0x09, 0xaa, + 0x9f, 0x91, 0x3c, 0x65, 0xe2, 0x81, 0xdb, 0xe8, + 0x5a, 0xe3, 0x74, 0x11, 0x7b, 0xec, 0x2f, 0x18, + 0x8d, 0x4c, 0x8f, 0xf2, 0x06, 0x3d, 0x22, 0xc6, + 0x43, 0xef, 0x42, 0x7d, 0xe1, 0xe7, 0xde, 0x4c, + 0x58, 0xad, 0x40, 0xbb, 0x8b, 0xce, 0x1f, 0x57, + 0x8e, 0x6a, 0x27, 0x43, 0x46, 0x7f, 0x94, 0xe5, + 0x45, 0x67, 0x12, 0xc8, 0x99, 0x85, 0x08, 0x2a, + 0x37, 0x40, 0x0b, 0xb5, 0xd9, 0xa3, 0xf7, 0xc8, + 0x87, 0xb1, 0xe6, 0x87, 0x2f, 0x86, 0xd8, 0x9c, + 0x7b, 0xec, 0xcf, 0xa4, 0xe5, 0xd5, 0x50, 0x3f, + 0xdf, 0xc9, 0xb7, 0x29, 0x97, 0xd6, 0x33, 0xba, + 0xf0, 0x72, 0xf0, 0x76, 0x12, 0xd3, 0x99, 0x4f, + 0x1b, 0x36, 0xda, 0xa1, 0x83, 0xfe, 0xf5, 0x94, + 0x9e, 0x61, 0x82, 0x62, 0xe0, 0x08, 0x3a, 0xbd, + 0xba, 0x8b, 0x3d, 0xd6, 0xbd, 0x16, 0x5f, 0xd7, + 0x1d, 0x6c, 0x0e, 0x92, 0x89, 0x8c, 0x38, 0x62, + 0x80, 0xee, 0x7e, 0x63, 0x82, 0x88, 0x0b, 0xbf, + 0xdd, 0x9f, 0xbc, 0xba, 0xa7, 0x5a, 0xc6, 0x0d, + 0x87, 0x59, 0xbf, 0x0a, 0x85, 0x06, 0xa3, 0xb4, + 0x66, 0x63, 0xda, 0x12, 0x29, 0x5f, 0x2e, 0x4d, + 0x60, 0xfd, 0x85, 0x76, 0xaf, 0xf7, 0x87, 0xed, + 0x1f, 0x46, 0xc2, 0xd6, 0x6c, 0x98, 0x6b, 0x4b, + 0x60, 0x04, 0xed, 0x89, 0x3b, 0x85, 0x6c, 0xe9, + 0x46, 0xd9, 0xfa, 0x35, 0x61, 0xe8, 0x0c, 0x84, + 0x1b, 0x93, 0xc0, 0xfe, 0x5d, 0x29, 0x14, 0xe1, + 0x1c, 0x66, 0x73, 0xc8, 0x0b, 0x98, 0xff, 0x1a, + 0x78, 0x2b, 0x6a, 0x93, 0x7a, 0x29, 0xd8, 0x7b, + 0xb1, 0x39, 0xf0, 0xad, 0x93, 0x4d, 0x2d, 0xab, + 0x67, 0x3c, 0xa4, 0xa1, 0x08, 0x36, 0x0b, 0xe9, + 0x77, 0xd0, 0xe3, 0x45, 0x7d, 0x99, 0x75, 0xc3, +}; + +/* + * IV method encblkno1, blkno 1. + */ +static const uint8_t aes_cbc_192_encblkno1_vec1_ctxt[SECSIZE] = { + 0xe6, 0x41, 0x75, 0xd6, 0x80, 0xdf, 0x44, 0x37, + 0xa7, 0xa2, 0xb2, 0x29, 0x0d, 0xf0, 0x02, 0x78, + 0x92, 0xb2, 0x06, 0x5f, 0x86, 0xd3, 0x9c, 0xa3, + 0xd0, 0xc5, 0x08, 0x03, 0x6d, 0x41, 0x9d, 0x61, + 0xb4, 0xb9, 0xa1, 0x69, 0x6e, 0x3a, 0x78, 0xd7, + 0x04, 0x94, 0xf2, 0x53, 0xed, 0xd1, 0xf6, 0xd8, + 0x98, 0xe2, 0x49, 0x75, 0x15, 0x85, 0xe0, 0x78, + 0x5b, 0x28, 0x5e, 0xe6, 0xfa, 0x60, 0x3d, 0x4b, + 0x8c, 0xf1, 0x1a, 0xfd, 0x1f, 0xe8, 0xad, 0xb4, + 0xa1, 0xe7, 0xd3, 0x71, 0x16, 0xdf, 0xc6, 0x95, + 0xd4, 0x43, 0xaf, 0x92, 0xab, 0x74, 0x0f, 0x77, + 0x75, 0x4d, 0xd7, 0x13, 0x97, 0x18, 0xea, 0x43, + 0x92, 0x0d, 0x88, 0xc8, 0x41, 0xf7, 0x15, 0x34, + 0x0f, 0x63, 0xbf, 0x50, 0x18, 0xbe, 0x9d, 0x3b, + 0xfc, 0x17, 0x7d, 0x03, 0x39, 0xc2, 0x39, 0x28, + 0xb2, 0x23, 0x1c, 0x7f, 0x3f, 0x19, 0x6c, 0x2f, + 0x64, 0xbd, 0xc9, 0x7d, 0xbe, 0x98, 0xe0, 0x83, + 0xa4, 0x48, 0xfc, 0x89, 0xe7, 0xe0, 0x93, 0x93, + 0x7b, 0x15, 0x35, 0xaf, 0xf8, 0x00, 0x81, 0xcc, + 0x04, 0x80, 0x8b, 0x20, 0xc8, 0x6a, 0xb7, 0x5e, + 0x95, 0xce, 0x69, 0x50, 0x39, 0x88, 0x90, 0x41, + 0x3f, 0xa8, 0x62, 0x42, 0xf1, 0xa9, 0x56, 0xce, + 0x25, 0x53, 0x1d, 0x97, 0x5d, 0x3a, 0x4e, 0x6b, + 0x1f, 0xd6, 0xea, 0x20, 0x81, 0x6c, 0xe5, 0xa1, + 0x0d, 0x9a, 0xd9, 0x3c, 0xbb, 0xbc, 0xc1, 0x77, + 0xe2, 0xf4, 0x9c, 0x11, 0x3a, 0x2f, 0xd0, 0x77, + 0x10, 0xa6, 0x36, 0xd1, 0xbf, 0x3b, 0x50, 0x39, + 0x4b, 0x2c, 0x62, 0x06, 0x1a, 0xe4, 0x18, 0xc0, + 0x35, 0x7c, 0xc3, 0xd0, 0x22, 0xf8, 0xee, 0x19, + 0xa5, 0x3d, 0x69, 0xa9, 0x34, 0xe6, 0x29, 0xf9, + 0xf1, 0xff, 0x26, 0x7a, 0x66, 0x13, 0x1a, 0xa2, + 0xc6, 0xac, 0x84, 0xf6, 0x6b, 0x09, 0xbd, 0x32, + 0x6f, 0x26, 0x37, 0x7c, 0x7d, 0x74, 0xe4, 0xa0, + 0xeb, 0x85, 0x7a, 0xa1, 0x92, 0x19, 0x2e, 0x64, + 0x82, 0x7c, 0x89, 0x1b, 0x14, 0x92, 0xd1, 0xf4, + 0x1f, 0x29, 0x84, 0x04, 0x70, 0x09, 0x13, 0x4c, + 0x62, 0x9a, 0xb4, 0xf7, 0xc1, 0x7b, 0x83, 0xd1, + 0x2d, 0x1a, 0xbe, 0x83, 0x9b, 0x73, 0xba, 0x8d, + 0xbb, 0xb0, 0xf2, 0x5c, 0x72, 0x75, 0x01, 0x0b, + 0xa6, 0x43, 0x6b, 0x76, 0x56, 0x4e, 0x71, 0x1b, + 0xb2, 0x34, 0x1f, 0x70, 0x44, 0xe6, 0xfb, 0x67, + 0xd1, 0x4d, 0x63, 0xce, 0x17, 0x46, 0x9b, 0x11, + 0xda, 0x93, 0xf8, 0x03, 0x11, 0x8f, 0x90, 0xff, + 0x80, 0x85, 0x02, 0x1f, 0xb6, 0x6a, 0x28, 0x3f, + 0x01, 0xa8, 0x36, 0x2e, 0xc7, 0x42, 0xd4, 0x02, + 0x26, 0xea, 0xb5, 0x84, 0x6c, 0x9f, 0xa0, 0x4a, + 0x73, 0x49, 0xea, 0x91, 0x4d, 0x62, 0xf8, 0x23, + 0xe4, 0x3d, 0x91, 0xfb, 0x53, 0x2c, 0x8c, 0xa4, + 0xfe, 0x81, 0x05, 0x5d, 0x4b, 0x9a, 0x75, 0x29, + 0xf8, 0xbe, 0x3f, 0x05, 0xb4, 0x8f, 0xdc, 0xcc, + 0xfa, 0xcc, 0xd7, 0xb2, 0x06, 0x03, 0xd4, 0xf3, + 0x8e, 0x09, 0x09, 0x80, 0xf8, 0xc3, 0x3b, 0x66, + 0xe9, 0x9c, 0x5b, 0x16, 0xed, 0x2d, 0x35, 0x1c, + 0x99, 0x3b, 0x1f, 0x0e, 0x04, 0x30, 0x23, 0x3a, + 0x83, 0x0c, 0xec, 0x76, 0xf2, 0x5d, 0x13, 0x54, + 0x15, 0x62, 0x36, 0x26, 0x6b, 0x21, 0x62, 0xdd, + 0xb4, 0x1a, 0x57, 0x16, 0xfd, 0xa0, 0x9c, 0xfa, + 0x37, 0xb3, 0xda, 0xe0, 0x46, 0x91, 0xb3, 0x20, + 0xe7, 0xe2, 0xf3, 0x0e, 0x20, 0x3c, 0x98, 0x1b, + 0xe4, 0xc2, 0xd3, 0xa9, 0x97, 0xaf, 0x12, 0x69, + 0x23, 0x97, 0x62, 0x6e, 0xae, 0x54, 0x9c, 0x82, + 0x92, 0x50, 0x74, 0x07, 0x4a, 0xb1, 0xdc, 0xcf, + 0x53, 0x1d, 0xc8, 0x29, 0x1f, 0x6e, 0xf1, 0x13, + 0xec, 0xb6, 0x60, 0xb1, 0x4c, 0x9d, 0xd7, 0x77, +}; + +/* + * IV method encblkno1, blkno 2. + */ +static const uint8_t aes_cbc_192_encblkno1_vec2_ctxt[SECSIZE] = { + 0x33, 0xfd, 0xfa, 0x44, 0x64, 0x75, 0x22, 0x7e, + 0xe3, 0xb3, 0xa0, 0x75, 0x99, 0x96, 0xc0, 0xec, + 0x56, 0x06, 0x7d, 0x19, 0x0b, 0x66, 0x89, 0xe0, + 0x69, 0x1d, 0x93, 0x91, 0xd7, 0x0f, 0xf8, 0xf5, + 0x5a, 0x39, 0x30, 0xad, 0x64, 0x42, 0x06, 0xa3, + 0xce, 0x3f, 0x67, 0xd6, 0x6e, 0xcd, 0x3b, 0xf5, + 0x03, 0x2b, 0x07, 0x83, 0x18, 0x1a, 0x4f, 0x4c, + 0xe7, 0x6b, 0xe8, 0xf9, 0x19, 0xa5, 0x23, 0x8f, + 0x46, 0x35, 0x13, 0x7b, 0x61, 0x05, 0xfc, 0x7d, + 0x17, 0x39, 0x03, 0xa8, 0xec, 0x7a, 0xd2, 0x5f, + 0x91, 0xa7, 0x26, 0x07, 0x9d, 0xd7, 0x0c, 0xd7, + 0xd4, 0x8e, 0x37, 0xf3, 0x1a, 0x3c, 0x04, 0x83, + 0x04, 0x71, 0x06, 0xa6, 0x5f, 0x82, 0xe0, 0x6d, + 0x87, 0x5c, 0x7c, 0x03, 0x25, 0x03, 0x4b, 0x24, + 0x07, 0x40, 0xad, 0xe4, 0x1d, 0x1d, 0xcb, 0x34, + 0xc2, 0x53, 0x1d, 0x13, 0xc5, 0x87, 0xab, 0xa7, + 0x95, 0x11, 0x8b, 0xbb, 0xf0, 0xc3, 0x00, 0xeb, + 0xe5, 0xb0, 0x9e, 0x88, 0x8b, 0xad, 0xca, 0xcb, + 0x17, 0xf8, 0x92, 0x4d, 0x00, 0xb0, 0x08, 0x74, + 0x08, 0xb9, 0x8b, 0x95, 0x96, 0xd9, 0x36, 0x35, + 0x31, 0x92, 0x89, 0xf6, 0x35, 0x33, 0xfb, 0x18, + 0x5b, 0x84, 0xa1, 0xfe, 0xe1, 0x62, 0x04, 0x6f, + 0x3c, 0xc1, 0xd2, 0xc2, 0x10, 0xd7, 0x97, 0xba, + 0x29, 0x7c, 0xe3, 0x85, 0xee, 0x59, 0x90, 0xaf, + 0x7f, 0x6f, 0x97, 0x97, 0xa2, 0x41, 0x18, 0x7f, + 0x2f, 0x06, 0x15, 0xb2, 0x46, 0x82, 0x49, 0x39, + 0xd0, 0xfb, 0xa8, 0x48, 0x44, 0x28, 0x58, 0xff, + 0xd8, 0xf2, 0x65, 0xf9, 0x4f, 0x2c, 0xbe, 0xec, + 0xb6, 0xdf, 0x27, 0x1a, 0xf2, 0x05, 0x15, 0x5e, + 0xe3, 0x2a, 0x98, 0x29, 0x92, 0x4a, 0x1b, 0x5d, + 0x5c, 0x2c, 0x70, 0xf6, 0x41, 0xd4, 0xbe, 0x64, + 0xa1, 0xd9, 0x79, 0xf1, 0x11, 0x16, 0xda, 0xa2, + 0xaf, 0xdd, 0x4d, 0xa8, 0xed, 0xec, 0xbe, 0x7d, + 0x49, 0x6c, 0x30, 0xf2, 0xf5, 0x36, 0x3c, 0xae, + 0x4b, 0xa7, 0x77, 0xa3, 0xca, 0x22, 0xa5, 0xe2, + 0x4d, 0x44, 0xcb, 0x36, 0xd5, 0x3f, 0x20, 0x13, + 0xb6, 0xfb, 0xcd, 0x79, 0xd7, 0x42, 0xf9, 0x75, + 0x09, 0x45, 0x28, 0x9e, 0xf2, 0xbd, 0x15, 0x57, + 0xf8, 0x4b, 0xc0, 0xd3, 0xb3, 0xb8, 0xde, 0x55, + 0x9e, 0x11, 0x67, 0xab, 0xc5, 0x5d, 0x58, 0xdb, + 0x4d, 0x20, 0x34, 0x77, 0x33, 0x9c, 0x46, 0x76, + 0x9b, 0x1e, 0x0e, 0x6b, 0x4e, 0xd9, 0x63, 0x68, + 0x78, 0x5e, 0x7c, 0x52, 0xa2, 0x64, 0xa9, 0xfc, + 0x21, 0x35, 0x17, 0x93, 0x18, 0x9e, 0x10, 0xcf, + 0x95, 0x6b, 0xf0, 0x55, 0x46, 0xc3, 0x4b, 0xfc, + 0x86, 0x8b, 0x0d, 0x3b, 0x5c, 0x30, 0xcc, 0xf1, + 0x4c, 0x43, 0xf0, 0xd6, 0xf6, 0x3b, 0x0b, 0x68, + 0x6f, 0x21, 0xd1, 0x61, 0xda, 0x35, 0x92, 0x94, + 0xa5, 0x5d, 0x47, 0x39, 0x96, 0x50, 0x5f, 0xbd, + 0x57, 0x22, 0xd2, 0x65, 0x73, 0x05, 0x8f, 0x2b, + 0xf2, 0x96, 0x53, 0x6b, 0x8e, 0xd3, 0x1e, 0xe7, + 0x92, 0xd4, 0xea, 0x41, 0xee, 0x92, 0x4d, 0x10, + 0x9f, 0x68, 0xd8, 0xe9, 0xac, 0x1f, 0x38, 0x0b, + 0x12, 0xa4, 0x1c, 0xb2, 0x63, 0x2b, 0x87, 0x07, + 0xb8, 0x1e, 0x02, 0x2b, 0x4d, 0xad, 0x99, 0xdf, + 0xe3, 0x98, 0x69, 0x29, 0x11, 0xe3, 0x77, 0x45, + 0x9a, 0xe9, 0x6c, 0x47, 0x4e, 0xc0, 0x85, 0x15, + 0x68, 0x58, 0x41, 0x37, 0xab, 0x96, 0x11, 0x94, + 0x9e, 0xbb, 0xa8, 0x5d, 0x51, 0x05, 0x93, 0xdd, + 0x2e, 0xb8, 0xdf, 0xcf, 0x83, 0xbc, 0xf6, 0x53, + 0x95, 0x93, 0x27, 0xda, 0xa5, 0x20, 0x1b, 0x7d, + 0x1d, 0xd9, 0x0c, 0xde, 0xe5, 0x3f, 0xc8, 0x60, + 0x16, 0x32, 0x95, 0x24, 0xa7, 0x2b, 0x74, 0xf1, + 0x67, 0xf9, 0xf2, 0x49, 0xda, 0x12, 0x97, 0xdd, +}; + +/* + * IV method encblkno1, blkno 3. + */ +static const uint8_t aes_cbc_192_encblkno1_vec3_ctxt[SECSIZE] = { + 0xa5, 0x81, 0x86, 0x78, 0x4a, 0xd7, 0x5b, 0x83, + 0xcf, 0xbf, 0x7e, 0x3c, 0xd7, 0xcd, 0xaf, 0xfa, + 0x82, 0x18, 0xce, 0xbd, 0x8b, 0xe6, 0xd9, 0x39, + 0x22, 0x2d, 0x1e, 0x75, 0x65, 0xee, 0x61, 0xf2, + 0xc3, 0x8b, 0xf4, 0x40, 0x03, 0x73, 0x8a, 0x21, + 0x9f, 0xf3, 0xcc, 0x93, 0x08, 0x3d, 0xff, 0x8a, + 0xbc, 0x0f, 0x19, 0xa1, 0x9f, 0xc8, 0x73, 0xe8, + 0xa6, 0x14, 0x2e, 0x43, 0x19, 0x79, 0x61, 0x35, + 0x8d, 0x55, 0x06, 0xeb, 0x96, 0xe7, 0xf5, 0x4b, + 0x95, 0x5f, 0x9b, 0xb2, 0x18, 0x0d, 0x13, 0xc2, + 0x96, 0x79, 0x50, 0x78, 0x98, 0x50, 0x88, 0x2b, + 0xab, 0x05, 0x66, 0xa1, 0x3a, 0x25, 0x85, 0xe2, + 0xd0, 0xe2, 0xac, 0xb5, 0x26, 0xde, 0x95, 0x04, + 0x45, 0xe7, 0x22, 0x71, 0x02, 0xb3, 0x84, 0x4c, + 0xb5, 0xad, 0x64, 0x5c, 0x27, 0x5c, 0x71, 0xcd, + 0x0b, 0x62, 0x91, 0xd6, 0x84, 0x00, 0x62, 0x52, + 0x54, 0xbd, 0x22, 0xc8, 0x57, 0xa7, 0x41, 0xac, + 0xc7, 0xa8, 0x56, 0x6f, 0x1b, 0x7e, 0xce, 0x02, + 0x29, 0x3b, 0xc0, 0x5d, 0x8e, 0x11, 0xa9, 0x54, + 0xc2, 0xf2, 0xf0, 0x81, 0x6c, 0x9a, 0x24, 0x5b, + 0x81, 0x7d, 0xf3, 0x84, 0x93, 0xc6, 0x2a, 0xd4, + 0xd3, 0x1a, 0x2f, 0x97, 0x2e, 0x31, 0x8a, 0x62, + 0x43, 0xcb, 0xc7, 0x3d, 0x73, 0x8e, 0xd6, 0x86, + 0x17, 0x8f, 0x63, 0xd4, 0xb1, 0x50, 0x92, 0xce, + 0x90, 0x37, 0x91, 0xce, 0x37, 0x13, 0x8e, 0x61, + 0x21, 0xd8, 0x1a, 0xbf, 0x42, 0x65, 0x1d, 0x86, + 0x07, 0x04, 0x9b, 0xd1, 0xd3, 0x26, 0x6b, 0x7c, + 0xa1, 0x77, 0x54, 0x5b, 0x9f, 0x95, 0x62, 0x43, + 0xb3, 0x71, 0x1e, 0x4c, 0x32, 0xd1, 0x3e, 0xe8, + 0x60, 0x9c, 0x0c, 0x15, 0x55, 0xf0, 0x38, 0xb7, + 0x1e, 0x40, 0xe5, 0x26, 0x4e, 0x46, 0x49, 0x47, + 0x59, 0x3d, 0x49, 0x76, 0x28, 0xd3, 0xed, 0x03, + 0xdd, 0xf8, 0x1a, 0xf4, 0x1a, 0xfe, 0xe4, 0x03, + 0xb9, 0xa5, 0x8e, 0x7c, 0x91, 0x7a, 0xb2, 0x17, + 0x84, 0x97, 0x3f, 0x12, 0x68, 0xaa, 0xf5, 0x73, + 0xbc, 0x84, 0xdd, 0x03, 0x4a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, 0x40, 0x18, 0x35, 0x2e, 0x17, 0xa0, 0x6e, + 0x43, 0xe7, 0xac, 0x89, 0x96, 0x3c, 0x16, 0xe0, + 0xdb, 0x09, 0x51, 0x4a, 0x45, 0x33, 0x63, 0xe9, + 0x4e, 0x3f, 0x32, 0x34, 0x36, 0x43, 0xd5, 0x0c, + 0x5a, 0x2e, 0x0e, 0x8b, 0x80, 0xb7, 0xf4, 0xe4, + 0x99, 0x9b, 0x05, 0xf5, 0xb2, 0xe4, 0x03, 0xe4, +}; + +const struct testvec aes_cbc_192_1_vectors[] = { + { + .blkno = 0, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_192_encblkno1_vec0_ctxt, + }, + { + .blkno = 1, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_192_encblkno1_vec1_ctxt, + }, + { + .blkno = 2, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_192_encblkno1_vec2_ctxt, + }, + { + .blkno = 3, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_192_encblkno1_vec3_ctxt, + }, +}; + +/* + * IV method encblkno8, blkno 0. + */ +static const uint8_t aes_cbc_192_encblkno8_vec0_ctxt[SECSIZE] = { + 0x87, 0x9c, 0x05, 0xd6, 0x25, 0xb9, 0xe0, 0xbe, + 0x78, 0x21, 0x85, 0x81, 0x8e, 0x2f, 0x13, 0x5e, + 0xf2, 0x73, 0x11, 0xfa, 0x73, 0x77, 0x93, 0x5e, + 0x71, 0x16, 0x98, 0x68, 0x6f, 0xe8, 0x22, 0x34, + 0xf5, 0x11, 0xfa, 0x61, 0xe6, 0x1a, 0xfb, 0x42, + 0xa7, 0xa3, 0x2e, 0x0d, 0xc1, 0x9d, 0x7d, 0xd9, + 0xfb, 0xbb, 0xc5, 0x08, 0x9d, 0xc2, 0xab, 0x5c, + 0xdf, 0x9b, 0x3c, 0x1a, 0xbd, 0x66, 0x5a, 0x91, + 0x1c, 0x00, 0x59, 0x2e, 0x92, 0xe9, 0x23, 0xf6, + 0x90, 0x3d, 0x5b, 0x72, 0x76, 0x78, 0xd9, 0xa2, + 0x48, 0x33, 0x29, 0xe2, 0xfd, 0x77, 0x14, 0xda, + 0x01, 0x92, 0x63, 0xdd, 0x8c, 0x1c, 0x2e, 0xf7, + 0x61, 0xfb, 0xc5, 0x76, 0xec, 0x7f, 0xef, 0xdc, + 0xbe, 0x2d, 0x3b, 0x69, 0x30, 0xb9, 0x08, 0x00, + 0xe8, 0x37, 0x09, 0xaa, 0x2a, 0x02, 0x80, 0x11, + 0x91, 0x16, 0x94, 0x7d, 0xb5, 0xdc, 0x9f, 0xb3, + 0xb0, 0x26, 0x72, 0x85, 0x93, 0x85, 0x19, 0x08, + 0x97, 0xef, 0x97, 0x57, 0xa8, 0x76, 0x0e, 0x85, + 0xb1, 0x1d, 0x79, 0xe3, 0x7a, 0xe8, 0x06, 0x3b, + 0xc4, 0x00, 0xbd, 0xaa, 0xd9, 0x17, 0x81, 0x37, + 0x12, 0x86, 0x52, 0xea, 0x04, 0xb2, 0x11, 0x0f, + 0x5a, 0x08, 0x68, 0xcb, 0x48, 0xca, 0x2f, 0xda, + 0xa3, 0x0a, 0x60, 0x57, 0xc7, 0x80, 0x36, 0x60, + 0x05, 0xce, 0xd5, 0x43, 0xc9, 0xbc, 0x6c, 0xe6, + 0x63, 0x38, 0x2e, 0x81, 0x90, 0x34, 0x11, 0x2c, + 0x84, 0x0c, 0x62, 0x68, 0xde, 0x17, 0x57, 0x43, + 0x19, 0xa5, 0x92, 0x9d, 0x91, 0x2b, 0xa2, 0x95, + 0x7c, 0x20, 0x72, 0xaa, 0x83, 0x24, 0x54, 0x94, + 0x10, 0x80, 0xd4, 0x3f, 0x58, 0xb9, 0x7b, 0x74, + 0x68, 0xd5, 0xfb, 0x3e, 0xdd, 0xb4, 0xdf, 0x65, + 0x72, 0x88, 0x45, 0x8a, 0xd0, 0x93, 0x6e, 0x99, + 0x84, 0xad, 0x39, 0x73, 0x16, 0x88, 0xdc, 0x89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, 0x59, 0x02, 0x9f, 0x1c, + 0x40, 0xff, 0x6c, 0x67, 0xae, 0x49, 0x1a, 0x2a, + 0xab, 0xd9, 0x63, 0x25, 0x2d, 0x9b, 0xd8, 0x1a, + 0x41, 0xa6, 0xea, 0x72, 0xfd, 0x56, 0xa1, 0x57, + 0x59, 0xdd, 0xf5, 0xa3, 0xb2, 0x2f, 0x64, 0xb1, + 0xc5, 0xfe, 0x8d, 0x9b, 0x93, 0xd1, 0x51, 0x77, + 0x13, 0x50, 0x74, 0x30, 0x28, 0xe4, 0x7a, 0x06, + 0x69, 0xd4, 0xa8, 0x0a, 0xae, 0x02, 0x4a, 0x61, + 0x24, 0xc2, 0xcd, 0xc8, 0xd3, 0x12, 0x2e, 0xac, + 0x9a, 0x0c, 0x24, 0x06, 0xb8, 0x1e, 0x3d, 0x29, +}; + +/* + * IV method encblkno8, blkno 1. + */ +static const uint8_t aes_cbc_192_encblkno8_vec1_ctxt[SECSIZE] = { + 0x1e, 0x3b, 0x66, 0x76, 0xd9, 0x9e, 0xf7, 0x82, + 0x17, 0x76, 0x69, 0x4d, 0x64, 0x63, 0xf1, 0x01, + 0x81, 0x8a, 0xa4, 0x97, 0x05, 0x42, 0xdb, 0x8c, + 0x27, 0xc8, 0xfd, 0x08, 0x21, 0x17, 0x87, 0xa9, + 0x0c, 0x86, 0x2d, 0xda, 0x17, 0xd5, 0x5d, 0x67, + 0x12, 0x93, 0x8d, 0x34, 0x5a, 0xfc, 0x2a, 0x49, + 0x1a, 0x1a, 0x77, 0x20, 0xfb, 0x1d, 0x5d, 0xd8, + 0x99, 0xb0, 0x8f, 0x1c, 0x13, 0x4d, 0x28, 0x6d, + 0x2d, 0x79, 0xa9, 0x8e, 0x04, 0x0c, 0x5a, 0xd5, + 0x52, 0x09, 0x15, 0x4a, 0xfb, 0x7a, 0xf8, 0xdc, + 0x3b, 0x77, 0xaf, 0xe0, 0x80, 0x6b, 0xac, 0x5f, + 0xc0, 0x0f, 0x0f, 0x29, 0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x20, 0x7b, 0x49, 0x47, 0x87, + 0xff, 0xf0, 0xe8, 0x7e, 0xcf, 0xc4, 0x2c, 0x02, + 0xdd, 0x53, 0xe9, 0x79, 0xc7, 0x6d, 0x16, 0x9f, + 0x2b, 0xd7, 0x1a, 0x36, 0x25, 0x5c, 0xba, 0x5c, + 0xdb, 0x44, 0x88, 0x99, 0x32, 0x2e, 0xb6, 0x3f, + 0xb4, 0xdd, 0x15, 0xeb, 0xec, 0x2a, 0x9e, 0xc5, + 0x37, 0x30, 0x2a, 0xd5, 0xc4, 0x2a, 0x9b, 0x40, + 0x97, 0x83, 0x94, 0xe7, 0x79, 0x79, 0x63, 0x4b, +}; + +/* + * IV method encblkno8, blkno 2. + */ +static const uint8_t aes_cbc_192_encblkno8_vec2_ctxt[SECSIZE] = { + 0x34, 0x07, 0x20, 0x14, 0x64, 0x0b, 0xa2, 0x2c, + 0xed, 0xba, 0x46, 0x24, 0xa0, 0xe6, 0x99, 0x8a, + 0x20, 0x75, 0x5f, 0x9f, 0x2a, 0x10, 0xa6, 0x1c, + 0x52, 0x60, 0x18, 0x67, 0xd6, 0x0d, 0x90, 0x4e, + 0xbc, 0x25, 0x5f, 0x81, 0xb4, 0x10, 0xdb, 0xd9, + 0xaf, 0x36, 0x84, 0x5c, 0x20, 0x25, 0x25, 0xbf, + 0x0d, 0xfa, 0xc5, 0x75, 0x2b, 0xec, 0xf2, 0xa6, + 0x69, 0x5c, 0xfe, 0xee, 0x21, 0xd8, 0x87, 0xdf, + 0xe3, 0x83, 0xeb, 0xb3, 0x3f, 0x5b, 0xda, 0x37, + 0x11, 0x05, 0xf7, 0xd8, 0xe0, 0x94, 0x08, 0x2b, + 0x75, 0x6b, 0xf3, 0x40, 0x53, 0x85, 0xde, 0x7a, + 0x64, 0xb1, 0x0e, 0x5f, 0x01, 0xb5, 0xfb, 0x74, + 0x48, 0x9a, 0xd4, 0x41, 0x33, 0x70, 0x9b, 0x08, + 0x7e, 0x34, 0x60, 0xfc, 0xf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0x77, 0xe8, 0x72, 0x31, + 0x4d, 0x2f, 0xe8, 0xa0, 0xf4, 0x7c, 0x25, 0x9c, + 0xcd, 0xa5, 0x7e, 0xd3, 0x30, 0xda, 0x46, 0xf5, + 0x48, 0x9e, 0x39, 0x34, 0x94, 0xd6, 0x24, 0x10, + 0xfc, 0x74, 0x2b, 0x6d, 0xcc, 0x00, 0x76, 0x3e, + 0x3b, 0x85, 0xfa, 0xef, 0x87, 0x70, 0x53, 0x4e, +}; + +/* + * IV method encblkno8, blkno 3. + */ +static const uint8_t aes_cbc_192_encblkno8_vec3_ctxt[SECSIZE] = { + 0xfe, 0xad, 0xf3, 0x4a, 0x9d, 0x64, 0x4e, 0x5d, + 0xaf, 0xa8, 0x44, 0x7e, 0xc9, 0x75, 0xe8, 0xd0, + 0x87, 0x73, 0x66, 0x4c, 0x77, 0x00, 0xfb, 0x7b, + 0x04, 0xe7, 0xd8, 0x82, 0x75, 0xe3, 0xa5, 0xbc, + 0xf3, 0x80, 0xae, 0x7c, 0xc9, 0x75, 0x9a, 0xc1, + 0x73, 0x49, 0x69, 0xf6, 0xa0, 0x49, 0x6e, 0x77, + 0x5f, 0x9b, 0x95, 0x9b, 0x9f, 0x41, 0x54, 0x57, + 0x0e, 0x3c, 0xe5, 0x2c, 0xbb, 0xbf, 0xd5, 0x76, + 0xf6, 0xb6, 0x05, 0xaa, 0x20, 0x5b, 0xdb, 0xcb, + 0x81, 0xad, 0x0c, 0x8a, 0x68, 0x94, 0x7d, 0x88, + 0xdc, 0x15, 0x6c, 0x89, 0x97, 0x53, 0x30, 0x96, + 0x4a, 0x54, 0xf9, 0x88, 0x00, 0xf7, 0x3b, 0x99, + 0xfc, 0x82, 0xe3, 0x48, 0xd2, 0x16, 0x2b, 0xba, + 0xd4, 0xba, 0x24, 0xd0, 0xd1, 0xb0, 0x8e, 0xcd, + 0x77, 0xdc, 0x01, 0xdf, 0xb2, 0x20, 0xc5, 0xa7, + 0x48, 0x2a, 0xcf, 0x56, 0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, + 0x61, 0xe3, 0x83, 0xa1, 0xd4, 0x2c, 0xb2, 0x2c, + 0x46, 0x5a, 0xbf, 0x96, 0xeb, 0xda, 0x45, 0x2d, + 0x25, 0x37, 0x69, 0x1a, 0x6b, 0xd6, 0xbc, 0xe1, + 0x28, 0x65, 0xf9, 0xfc, 0xa7, 0xda, 0xf8, 0x79, + 0x87, 0x18, 0x99, 0x01, 0x74, 0x5a, 0x42, 0x79, + 0x8e, 0xe4, 0x23, 0x1a, 0x6c, 0xda, 0x93, 0x0f, + 0x19, 0xf0, 0xff, 0x0e, 0x25, 0x45, 0x1e, 0xbb, + 0x17, 0xca, 0x87, 0x6a, 0x9e, 0xd0, 0xd3, 0xd5, + 0x22, 0x5f, 0xce, 0x92, 0xeb, 0x82, 0x8e, 0x3e, + 0x4e, 0x99, 0x44, 0xa2, 0x9e, 0x78, 0x53, 0x89, + 0x4e, 0x45, 0x51, 0x41, 0x28, 0x91, 0xdb, 0x7e, + 0x8f, 0xac, 0xc2, 0xee, 0x09, 0xcb, 0xed, 0x04, + 0x7b, 0x37, 0xa1, 0x1d, 0x9c, 0x90, 0x19, 0xb1, + 0xdd, 0xc3, 0x22, 0xc8, 0x70, 0x07, 0x26, 0xce, + 0x4a, 0xc4, 0xde, 0xee, 0x87, 0xf3, 0x62, 0x69, + 0xed, 0xb2, 0x2d, 0x10, 0xc4, 0xfa, 0x86, 0x2e, + 0xd1, 0xb8, 0x58, 0xa3, 0xa4, 0x0b, 0x30, 0x87, + 0x23, 0x62, 0xed, 0xf3, 0x7b, 0x80, 0x7e, 0x4f, + 0xc2, 0xb3, 0xe8, 0xba, 0x25, 0x3e, 0xd3, 0x12, + 0x7e, 0x27, 0xd5, 0x72, 0x3b, 0x02, 0xf4, 0xfd, + 0x2f, 0x8b, 0xc2, 0x5f, 0x44, 0x40, 0x31, 0x88, + 0x73, 0x81, 0xa3, 0xcc, 0xc4, 0x78, 0x2b, 0xfc, + 0x41, 0x2e, 0xb2, 0xd0, 0xb4, 0x00, 0x29, 0xc1, + 0x46, 0xdf, 0xc1, 0xbd, 0x15, 0x59, 0xa3, 0x6a, + 0xc8, 0x2f, 0x29, 0x28, 0x12, 0x9b, 0x1e, 0xea, + 0x4e, 0xa9, 0x80, 0xa1, 0xb8, 0x89, 0x21, 0x3b, +}; + +const struct testvec aes_cbc_192_8_vectors[] = { + { + .blkno = 0, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_192_encblkno8_vec0_ctxt, + }, + { + .blkno = 1, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_192_encblkno8_vec1_ctxt, + }, + { + .blkno = 2, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_192_encblkno8_vec2_ctxt, + }, + { + .blkno = 3, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_192_encblkno8_vec3_ctxt, + }, +}; + +/* + * IV method encblkno1, blkno 0. + */ +static const uint8_t aes_cbc_256_encblkno1_vec0_ctxt[SECSIZE] = { + 0x1a, 0xa4, 0xe3, 0x09, 0x23, 0x2e, 0x91, 0x1b, + 0xa8, 0x3e, 0xda, 0x92, 0xb3, 0x22, 0xd2, 0xe8, + 0x8b, 0xed, 0x6c, 0xa7, 0x78, 0xe6, 0x32, 0x25, + 0xc4, 0x88, 0xd5, 0xb7, 0x6e, 0xef, 0xbf, 0x37, + 0x00, 0xd9, 0xb2, 0x55, 0x10, 0x4f, 0x7d, 0x84, + 0x3a, 0xae, 0xd2, 0xc6, 0x48, 0xdd, 0x3c, 0xd5, + 0x9b, 0xa7, 0xf8, 0xc2, 0xda, 0x6d, 0x14, 0xa2, + 0xdc, 0x54, 0x12, 0x8f, 0x1c, 0x22, 0x98, 0x6a, + 0xc0, 0x5f, 0x47, 0xa7, 0x78, 0xec, 0x79, 0x5d, + 0x04, 0xed, 0x5e, 0x20, 0x33, 0x53, 0x66, 0x40, + 0x83, 0x94, 0x5b, 0x34, 0x05, 0x25, 0x2e, 0x17, + 0xba, 0x23, 0x60, 0xb1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x02, + 0x64, 0xdc, 0xa0, 0x15, 0xc8, 0xf6, 0x17, 0x8b, + 0x9c, 0xb3, 0xf2, 0x27, 0xc1, 0x3f, 0x60, 0x94, + 0x33, 0x10, 0x89, 0x49, 0x5f, 0xd2, 0x0e, 0xfe, + 0x9e, 0x99, 0x68, 0x95, 0xe4, 0x12, 0xfc, 0xe3, + 0x7f, 0xc4, 0xb1, 0x88, 0x4f, 0x66, 0xcd, 0x24, + 0x89, 0x09, 0xbb, 0x01, 0xf6, 0x9a, 0xe4, 0x41, + 0xee, 0x83, 0xd2, 0x28, 0xf5, 0x28, 0x49, 0x13, + 0x78, 0xfb, 0xb2, 0x0d, 0x5c, 0x97, 0xf4, 0x9c, + 0xe0, 0xdf, 0xef, 0x84, 0x36, 0x7d, 0xe5, 0x45, + 0xe0, 0xf8, 0xce, 0x82, 0x39, 0xc4, 0x54, 0x69, + 0xf1, 0x62, 0x7d, 0x1a, 0xf6, 0x6c, 0x20, 0x86, + 0x72, 0x4b, 0xf9, 0x3d, 0x87, 0x68, 0xec, 0x74, + 0x67, 0xee, 0xbd, 0xb8, 0xc6, 0x12, 0x91, 0x0f, + 0xf6, 0xd9, 0x4f, 0x34, 0x96, 0xa9, 0xe7, 0x52, + 0x7b, 0xe0, 0x08, 0x57, 0x0a, 0x8b, 0x09, 0xcb, + 0xd3, 0x3e, 0x4e, 0x64, 0xca, 0x38, 0x50, 0x07, + 0x0e, 0x7b, 0x95, 0x69, 0x1b, 0x82, 0xba, 0x50, + 0x93, 0x4f, 0x9a, 0x8e, 0x11, 0x9b, 0x64, 0xf5, + 0x6a, 0xd4, 0x81, 0xf0, 0x1f, 0xb8, 0x85, 0x90, + 0x9c, 0x79, 0xde, 0xcb, 0x50, 0xba, 0xa9, 0x56, + 0x66, 0xd1, 0x1e, 0x78, 0xa8, 0x6a, 0xd5, 0xa5, + 0x83, 0x73, 0xe2, 0x88, 0xf2, 0x04, 0x33, 0x61, + 0xdf, 0x89, 0xd5, 0x3d, 0x03, 0x4e, 0x94, 0xb0, + 0x0f, 0x8d, 0x4d, 0xb4, 0x09, 0xb2, 0xf1, 0xb0, + 0xe7, 0xfe, 0xb0, 0x18, 0xe2, 0xfc, 0x92, 0xeb, + 0x2d, 0x7d, 0x56, 0x29, 0xbd, 0x34, 0x20, 0x7c, + 0xb6, 0xe7, 0x7b, 0xd7, 0x95, 0xa5, 0x0d, 0x10, + 0xbc, 0x7d, 0x9d, 0xd9, 0xbe, 0xc7, 0x23, 0x44, + 0x37, 0xb3, 0x98, 0x36, 0x33, 0x1a, 0x11, 0xfe, + 0x41, 0xea, 0x59, 0x48, 0x75, 0x34, 0xf6, 0xc4, +}; + +/* + * IV method encblkno1, blkno 1. + */ +static const uint8_t aes_cbc_256_encblkno1_vec1_ctxt[SECSIZE] = { + 0x58, 0xfc, 0x1e, 0x48, 0x66, 0x7d, 0x91, 0xc7, + 0x56, 0xa3, 0x41, 0x89, 0xe8, 0x1e, 0x02, 0x77, + 0x93, 0x38, 0x12, 0x99, 0x06, 0x0d, 0xf3, 0x6d, + 0x2a, 0x5d, 0x3d, 0x7b, 0x4e, 0x05, 0x4f, 0x8f, + 0xe3, 0x86, 0x76, 0xfe, 0x11, 0x9d, 0xde, 0xd4, + 0x83, 0xd9, 0x47, 0x8d, 0x51, 0xdf, 0x4a, 0x24, + 0x2d, 0x11, 0xf0, 0xbd, 0xde, 0x17, 0x7e, 0x52, + 0x20, 0xc7, 0x17, 0x88, 0x2e, 0xa4, 0xd5, 0xa0, + 0x1e, 0xbc, 0x61, 0x15, 0x1e, 0x52, 0xa1, 0x8b, + 0xe9, 0xe4, 0x1f, 0x81, 0x49, 0x64, 0x17, 0xd4, + 0xef, 0xb6, 0x40, 0x05, 0x2f, 0x36, 0xf7, 0x39, + 0x03, 0x05, 0x80, 0xff, 0xf2, 0x1a, 0x15, 0xf1, + 0xfc, 0xaf, 0x71, 0x51, 0x73, 0xc5, 0x9e, 0x2f, + 0xd1, 0x7a, 0x2d, 0xd7, 0xed, 0x90, 0x11, 0xd2, + 0x80, 0x49, 0x46, 0x9f, 0x13, 0xa7, 0x32, 0x33, + 0x24, 0x39, 0x59, 0xf1, 0xed, 0x64, 0x75, 0x61, + 0xc3, 0x14, 0x68, 0x48, 0xf7, 0xc7, 0xbd, 0xe0, + 0x21, 0x59, 0x91, 0x07, 0x70, 0x83, 0x8f, 0xfc, + 0x59, 0x72, 0xca, 0xdd, 0x60, 0xa0, 0xbb, 0xb1, + 0x2f, 0xb8, 0x98, 0x8d, 0xf2, 0x4d, 0x3a, 0x19, + 0xbc, 0x6b, 0x37, 0xad, 0xd2, 0xb5, 0x7d, 0x1c, + 0x4a, 0x7b, 0x58, 0x76, 0x2e, 0xf5, 0x6b, 0xaf, + 0x4c, 0x92, 0x00, 0x8a, 0xb4, 0xa3, 0x86, 0x66, + 0x07, 0xc7, 0xfc, 0x57, 0x3c, 0x73, 0xf4, 0x8b, + 0xef, 0xb6, 0xae, 0x01, 0xfb, 0x88, 0x13, 0x04, + 0xa8, 0xc7, 0xec, 0xc4, 0xe0, 0x67, 0x3a, 0xfb, + 0x67, 0xce, 0x83, 0x9b, 0x8e, 0x66, 0xff, 0xa6, + 0x17, 0x1b, 0x66, 0x27, 0xdf, 0x2a, 0xfe, 0xf3, + 0x9a, 0xba, 0x59, 0xce, 0x28, 0xd4, 0xd2, 0x40, + 0x78, 0xb6, 0xe9, 0x7d, 0x8b, 0xcc, 0x47, 0x5c, + 0xf6, 0x5d, 0xc2, 0x5d, 0xe0, 0xa7, 0x61, 0x8b, + 0xe6, 0x7d, 0x38, 0xb6, 0xea, 0xfb, 0x13, 0x31, + 0x33, 0x2a, 0xb5, 0x45, 0x7b, 0xf6, 0x9f, 0x29, + 0x06, 0x2d, 0xd8, 0xab, 0x36, 0x27, 0xe4, 0x6c, + 0xf1, 0xab, 0xcd, 0xb9, 0x08, 0x0f, 0x4b, 0x8f, + 0x22, 0xea, 0xe4, 0x5d, 0x22, 0x05, 0x2e, 0xd4, + 0xd7, 0x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c2, 0xd3, 0x35, 0x65, + 0xd8, 0x67, 0xc2, 0x9d, 0xed, 0xf7, 0x9f, 0x7b, + 0x7c, 0xd4, 0x03, 0xe0, 0xa6, 0xf9, 0x3c, 0xd0, + 0x21, 0x98, 0x60, 0xa6, 0x59, 0x86, 0xbd, 0x40, + 0x17, 0x47, 0x82, 0xb9, 0xe1, 0x11, 0x8d, 0x4b, + 0xcd, 0x1f, 0x54, 0x96, 0x17, 0x42, 0x22, 0x44, +}; + +/* + * IV method encblkno1, blkno 2. + */ +static const uint8_t aes_cbc_256_encblkno1_vec2_ctxt[SECSIZE] = { + 0x1d, 0x65, 0xb2, 0x4e, 0xfa, 0x3f, 0xdb, 0xab, + 0x34, 0x9d, 0x37, 0x03, 0x17, 0x44, 0xed, 0x5b, + 0xf7, 0x1b, 0x6b, 0xc0, 0x5c, 0xfe, 0x5b, 0xcd, + 0xf0, 0xaf, 0x26, 0x82, 0x97, 0x12, 0xb8, 0x4f, + 0x76, 0x3d, 0x07, 0xd8, 0x29, 0x56, 0x3c, 0xbd, + 0x0e, 0xac, 0xd1, 0x8f, 0x53, 0x1a, 0x8f, 0xcd, + 0x04, 0x5b, 0x49, 0xe0, 0xf0, 0xea, 0xc9, 0x8a, + 0x08, 0x3d, 0x1f, 0x2d, 0x8c, 0xec, 0xb8, 0xea, + 0xe9, 0x24, 0xd1, 0x93, 0xd7, 0x9a, 0x0f, 0xd7, + 0x0f, 0x6b, 0xa0, 0x08, 0x58, 0x81, 0x68, 0x2f, + 0xde, 0x36, 0xb5, 0x87, 0xd9, 0xcd, 0x82, 0x13, + 0x36, 0x16, 0x6a, 0x9a, 0x02, 0xca, 0xda, 0x6f, + 0x51, 0x87, 0x75, 0x47, 0x89, 0xa4, 0x10, 0x60, + 0xfb, 0x1a, 0x74, 0x55, 0x6d, 0x18, 0x8d, 0x42, + 0x74, 0x2d, 0x12, 0x56, 0xc0, 0xcd, 0xa2, 0x57, + 0x53, 0x31, 0x8c, 0x7a, 0x8b, 0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39, 0x6e, 0xc0, 0x37, + 0x31, 0x84, 0xff, 0xe2, 0x5a, 0xd6, 0x88, 0x74, + 0x15, 0x15, 0x46, 0x21, 0x00, 0xe4, 0x13, 0x9a, + 0xfa, 0xb2, 0x49, 0x7e, 0x79, 0xfb, 0x8a, 0x2a, +}; + +/* + * IV method encblkno1, blkno 3. + */ +static const uint8_t aes_cbc_256_encblkno1_vec3_ctxt[SECSIZE] = { + 0xc1, 0x4a, 0x3c, 0x90, 0xba, 0xd4, 0x9c, 0xe7, + 0xf2, 0x5b, 0x3a, 0xc4, 0xce, 0x4a, 0x26, 0x4a, + 0x9c, 0x3f, 0xe5, 0x7a, 0x15, 0xbb, 0xbd, 0x3e, + 0xc6, 0x49, 0x47, 0x04, 0x4e, 0x8b, 0x73, 0xa6, + 0x02, 0x3a, 0xc1, 0xa3, 0xfa, 0x1a, 0xd0, 0x03, + 0xf7, 0x26, 0x9f, 0xad, 0x06, 0x8f, 0x86, 0xdc, + 0xb8, 0x73, 0x87, 0xa2, 0x82, 0xc6, 0x80, 0xe1, + 0xac, 0x3d, 0x16, 0x4c, 0xc3, 0x7c, 0x86, 0x01, + 0xa5, 0x7a, 0x1c, 0x4b, 0x56, 0x68, 0xf6, 0x06, + 0x99, 0x32, 0x42, 0x40, 0xf1, 0xb7, 0x44, 0x4b, + 0xd1, 0xdb, 0xad, 0x4e, 0xa6, 0xc2, 0x5f, 0xee, + 0x21, 0x1d, 0x58, 0xc6, 0xd5, 0x02, 0xef, 0xb2, + 0x38, 0xef, 0x29, 0x25, 0xfd, 0x28, 0x8a, 0x5b, + 0x8b, 0x36, 0x1a, 0xd6, 0x68, 0xf8, 0x77, 0xed, + 0xba, 0xb3, 0xa5, 0x6f, 0x76, 0x5e, 0xb5, 0xd4, + 0xc3, 0xb8, 0xf9, 0x67, 0x7a, 0x18, 0x43, 0xb6, + 0x65, 0x07, 0x48, 0x1d, 0x56, 0x20, 0x11, 0xe1, + 0x62, 0x6b, 0x70, 0xc9, 0x18, 0xa9, 0xa7, 0x36, + 0xbf, 0x31, 0x74, 0xe3, 0x33, 0x02, 0x96, 0x7a, + 0xf5, 0xd9, 0x8d, 0x05, 0x2b, 0xfd, 0x85, 0x4f, + 0x03, 0x0f, 0xe1, 0xfb, 0x1a, 0x57, 0xaf, 0xdc, + 0xff, 0xff, 0x5a, 0x96, 0x27, 0xca, 0xf3, 0x0c, + 0xd8, 0x39, 0x3e, 0xbe, 0x41, 0x5a, 0x21, 0x95, + 0x66, 0xe0, 0x69, 0x14, 0x2b, 0x18, 0xf2, 0x9b, + 0xf4, 0x22, 0xdf, 0xa9, 0xe4, 0x7d, 0x32, 0x5d, + 0x98, 0xa0, 0xe0, 0xe1, 0xe1, 0xbe, 0xae, 0x58, + 0x63, 0xbe, 0x4b, 0x97, 0x83, 0xaa, 0x67, 0xd3, + 0x1a, 0x70, 0xca, 0x82, 0x98, 0x77, 0x74, 0x1a, + 0xf2, 0x3d, 0x6a, 0x7b, 0x8e, 0xc8, 0xca, 0x34, + 0x44, 0xb8, 0xc0, 0xd0, 0x77, 0x8c, 0x4a, 0x5c, + 0xae, 0xd3, 0x17, 0x7c, 0x12, 0x47, 0x3e, 0xe2, + 0x2e, 0x51, 0xe0, 0x52, 0x88, 0x8e, 0xe9, 0x68, + 0xb6, 0x13, 0xf8, 0x69, 0xc9, 0x4b, 0xdd, 0x91, + 0x27, 0xb0, 0x22, 0x0c, 0x7d, 0xad, 0xb0, 0x75, + 0xe8, 0x76, 0x34, 0xc2, 0xd9, 0xf3, 0x20, 0xf7, + 0x1d, 0x0f, 0x07, 0x61, 0xc2, 0xb8, 0x7d, 0x00, + 0xa6, 0x68, 0xad, 0xd4, 0x0b, 0xa4, 0xa0, 0x32, + 0x6d, 0xa5, 0xc0, 0x07, 0x65, 0xae, 0xda, 0x2e, + 0xd6, 0xb7, 0xd3, 0x99, 0x8b, 0x37, 0x08, 0x13, + 0x6a, 0x94, 0xe9, 0xe4, 0xea, 0x34, 0xee, 0x07, + 0xee, 0x77, 0xb1, 0x3f, 0x54, 0x05, 0xbe, 0x66, + 0x7f, 0xf2, 0x70, 0x34, 0x45, 0xa7, 0x4b, 0x27, + 0xef, 0xe6, 0x39, 0x2e, 0x13, 0x41, 0xdb, 0x2d, + 0x1f, 0x76, 0x11, 0x76, 0x33, 0xf3, 0x92, 0x33, + 0x69, 0x16, 0x34, 0x86, 0x23, 0xc5, 0xfa, 0xaf, + 0xff, 0xbf, 0xee, 0x84, 0x56, 0xf6, 0x1e, 0x54, + 0x37, 0x32, 0x79, 0x83, 0x45, 0x04, 0x6f, 0x0e, + 0x75, 0x75, 0xd9, 0xd6, 0x4a, 0x87, 0xfb, 0x3c, + 0xb1, 0xcf, 0x66, 0xab, 0xa4, 0xaa, 0xf6, 0x96, + 0xb0, 0xcd, 0xaf, 0xac, 0x2c, 0x6d, 0x72, 0xca, + 0x43, 0xef, 0xb7, 0xa0, 0x4c, 0x62, 0xba, 0x7e, + 0x59, 0x0b, 0xff, 0x90, 0x49, 0x63, 0xf6, 0x31, + 0x8b, 0x50, 0x20, 0x82, 0x7d, 0xf0, 0x2d, 0xe4, + 0x5b, 0xda, 0xdf, 0xb0, 0xfb, 0x07, 0x7b, 0xe3, + 0x5f, 0xac, 0xd8, 0xe5, 0xa0, 0x3e, 0xc5, 0x60, + 0x94, 0xbc, 0xf7, 0x7e, 0xdc, 0x18, 0x27, 0x20, + 0xb1, 0xdd, 0x51, 0x4a, 0xb2, 0xe0, 0xc0, 0xe7, + 0x5d, 0x0f, 0x88, 0xb2, 0xa0, 0x42, 0x73, 0xfb, + 0xc4, 0x24, 0xa7, 0x17, 0x8a, 0xc9, 0x6d, 0x34, + 0xe8, 0x7b, 0x51, 0x37, 0x32, 0x3f, 0xf8, 0x7e, + 0x92, 0xe4, 0x87, 0xd2, 0x89, 0x66, 0xb0, 0xf6, + 0xc2, 0xba, 0x2f, 0x42, 0x8f, 0x1d, 0x5d, 0x81, + 0xad, 0xfd, 0x00, 0xbc, 0xa9, 0x11, 0x96, 0xae, + 0x80, 0xf1, 0x27, 0xe0, 0xeb, 0x5b, 0x60, 0x39, +}; + +const struct testvec aes_cbc_256_1_vectors[] = { + { + .blkno = 0, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_256_encblkno1_vec0_ctxt, + }, + { + .blkno = 1, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_256_encblkno1_vec1_ctxt, + }, + { + .blkno = 2, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_256_encblkno1_vec2_ctxt, + }, + { + .blkno = 3, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_256_encblkno1_vec3_ctxt, + }, +}; + +/* + * IV method encblkno8, blkno 0. + */ +static const uint8_t aes_cbc_256_encblkno8_vec0_ctxt[SECSIZE] = { + 0xe5, 0x55, 0xd9, 0xae, 0xc0, 0x66, 0x2d, 0x2f, + 0x11, 0xb1, 0x27, 0xd2, 0xb2, 0x73, 0xe4, 0x0a, + 0x85, 0xb5, 0x3c, 0x79, 0x78, 0xd6, 0x35, 0x3d, + 0x46, 0xac, 0xa3, 0x81, 0x55, 0x76, 0x86, 0xfc, + 0x37, 0xa0, 0x95, 0xc2, 0x30, 0xc9, 0x19, 0xc2, + 0x5f, 0xb0, 0x13, 0xa2, 0xa8, 0xe1, 0xc7, 0xb7, + 0x61, 0x54, 0xd8, 0xe6, 0xca, 0x94, 0x6f, 0x47, + 0x87, 0x33, 0x58, 0xd9, 0xd5, 0xd2, 0x95, 0x73, + 0x87, 0x9a, 0x31, 0xe5, 0x2e, 0x95, 0x83, 0x7d, + 0xdc, 0x0f, 0xc5, 0x2f, 0x14, 0xbc, 0x80, 0xac, + 0x47, 0xd6, 0xd8, 0x17, 0x9e, 0xf7, 0xff, 0x5b, + 0x85, 0x05, 0x91, 0xe0, 0x73, 0xd2, 0x5c, 0xa7, + 0x41, 0xf8, 0xcb, 0x3d, 0x38, 0x14, 0x28, 0x3e, + 0x89, 0x6f, 0xd4, 0xac, 0xb6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x0e, 0x07, 0x69, 0x12, 0xc1, 0xbd, 0x13, 0xad, + 0xe2, 0xcf, 0x3d, 0x96, 0xd8, 0xaf, 0xed, 0xdc, + 0x4c, 0x72, 0xf6, 0xce, 0x15, 0x86, 0x88, 0x8c, + 0xbb, 0x60, 0xb3, 0xb9, 0xde, 0x42, 0x58, 0x6e, + 0xc4, 0x58, 0xac, 0x77, 0x8d, 0x35, 0x23, 0x5f, + 0xc3, 0xf9, 0x33, 0x46, 0x17, 0x80, 0x31, 0xfd, + 0xcd, 0x0a, 0x1e, 0x9b, 0xac, 0x42, 0xda, 0x70, + 0x54, 0x9a, 0xeb, 0x22, 0x27, 0x09, 0x0c, 0x6c, + 0x18, 0x1d, 0x1a, 0x5b, 0x86, 0x4d, 0x80, 0xca, + 0x4d, 0xda, 0x0e, 0x9a, 0x8e, 0x61, 0x04, 0x68, + 0x29, 0x08, 0x3b, 0xae, 0x14, 0x7d, 0x8e, 0x43, + 0x7a, 0xa7, 0x83, 0xcf, 0xb3, 0x95, 0xd3, 0x42, + 0x2d, 0x6b, 0xd8, 0x5c, 0x43, 0x31, 0x5b, 0x9c, + 0x18, 0x30, 0x0d, 0x61, 0x9c, 0xab, 0x29, 0x55, + 0xdd, 0x84, 0x24, 0x21, 0xec, 0x44, 0xad, 0xf3, + 0xb3, 0x70, 0x77, 0x2b, 0xfc, 0x3f, 0x99, 0xb8, + 0x50, 0x26, 0x8d, 0x96, 0xa2, 0x22, 0x99, 0x33, + 0x53, 0xa8, 0x5d, 0x84, 0x9b, 0x76, 0x26, 0x6e, + 0x75, 0x14, 0x7e, 0x63, 0xc6, 0x7a, 0x4f, 0x5c, + 0xfe, 0x4b, 0x80, 0xee, 0xb3, 0x32, 0x8d, 0x25, + 0x1c, 0x80, 0x7b, 0x3d, 0xd3, 0x84, 0x01, 0x1e, + 0x16, 0xa4, 0xca, 0x0d, 0x38, 0x40, 0x03, 0x6f, + 0x81, 0x8b, 0x5c, 0xad, 0x22, 0xfa, 0x6f, 0xeb, + 0x60, 0xa1, 0xcb, 0x2d, 0x97, 0xf8, 0xa6, 0x5e, + 0xbe, 0x93, 0xb7, 0xe6, 0x66, 0xbf, 0x9b, 0xd2, + 0x5c, 0x31, 0xcc, 0x70, 0x0c, 0xf1, 0xfb, 0x9f, + 0x09, 0x1b, 0xc2, 0x85, 0x2f, 0x22, 0x7c, 0x95, + 0x58, 0x09, 0xce, 0x9c, 0x7c, 0x50, 0xca, 0x89, +}; + +/* + * IV method encblkno8, blkno 1. + */ +static const uint8_t aes_cbc_256_encblkno8_vec1_ctxt[SECSIZE] = { + 0x37, 0x4d, 0x25, 0xdb, 0x35, 0xe0, 0x8b, 0x82, + 0x5f, 0x77, 0xd2, 0x53, 0xd1, 0x1f, 0xf0, 0x91, + 0x5b, 0xd8, 0x93, 0x2f, 0xb2, 0x81, 0xbd, 0x75, + 0xf0, 0xd8, 0xff, 0x46, 0x8c, 0x9d, 0xf6, 0xe2, + 0x99, 0x1e, 0x76, 0x9d, 0x00, 0x3a, 0xe3, 0xcf, + 0x6d, 0x24, 0xa8, 0xe8, 0xb4, 0xa7, 0xa0, 0x87, + 0xa8, 0x43, 0x01, 0x21, 0x29, 0x70, 0x39, 0x2d, + 0x0b, 0x2a, 0xe9, 0x11, 0x57, 0x86, 0x13, 0xd4, + 0x1c, 0x1b, 0x59, 0x19, 0xc4, 0x7d, 0x2c, 0x94, + 0xc7, 0x01, 0xb8, 0x96, 0x01, 0xd2, 0x01, 0x17, + 0x97, 0x41, 0x68, 0xab, 0xba, 0x9c, 0xc8, 0xad, + 0x4e, 0xd7, 0xa8, 0x4c, 0x96, 0x3f, 0xf9, 0xfc, + 0x7e, 0xd7, 0x59, 0xe8, 0x25, 0x51, 0x4d, 0x1d, + 0x99, 0xfd, 0x0b, 0xe9, 0x88, 0x23, 0xd1, 0x4b, + 0x30, 0x6e, 0x18, 0x7c, 0xe3, 0x7a, 0x54, 0x2a, + 0x4f, 0x2a, 0x99, 0x8f, 0xaf, 0xd7, 0x5e, 0x25, + 0xfe, 0x9c, 0x47, 0x09, 0x63, 0x38, 0x0d, 0x5f, + 0xb3, 0x43, 0xa6, 0x66, 0x9b, 0xc5, 0x3d, 0x88, + 0x5e, 0xc7, 0x60, 0x99, 0x8e, 0xcb, 0x6a, 0x65, + 0x60, 0x92, 0x88, 0xe1, 0x2b, 0xfe, 0x83, 0x34, + 0x92, 0xa6, 0x6c, 0x22, 0x56, 0x5b, 0x75, 0x8a, + 0x93, 0xc3, 0x72, 0xca, 0xff, 0x59, 0x3b, 0xd8, + 0xa0, 0x80, 0x56, 0x98, 0x62, 0x8a, 0x70, 0xf2, + 0x5d, 0xd9, 0x40, 0x6b, 0xbf, 0x9f, 0x71, 0x8d, + 0x2e, 0x38, 0xe8, 0x06, 0x42, 0xa9, 0x95, 0x70, + 0x31, 0xd1, 0xe9, 0x6c, 0xab, 0xbb, 0xed, 0x25, + 0xe8, 0xca, 0xe8, 0xa4, 0x98, 0x82, 0xf5, 0xe3, + 0x11, 0x3c, 0xc4, 0xea, 0xea, 0x88, 0x56, 0x91, + 0xd6, 0x5d, 0xaa, 0xf7, 0xe9, 0x49, 0x2f, 0x42, + 0x5b, 0x76, 0xef, 0xed, 0x03, 0x9e, 0x5f, 0x4d, + 0x65, 0x25, 0xa5, 0xe8, 0x26, 0xba, 0x03, 0x4f, + 0x0e, 0x39, 0xd2, 0x53, 0x62, 0x98, 0x81, 0x9d, + 0x8e, 0xad, 0x50, 0x17, 0x9f, 0xcc, 0x34, 0x45, + 0x19, 0x5c, 0x1c, 0xd1, 0xbc, 0x71, 0x89, 0xaa, + 0x9a, 0x65, 0x55, 0x6f, 0x78, 0xd4, 0xd3, 0x5b, + 0x27, 0x8d, 0x94, 0x46, 0xd9, 0x95, 0xb3, 0x5f, + 0xc4, 0x35, 0x8d, 0xba, 0x1c, 0x40, 0x52, 0xd1, + 0x99, 0x27, 0x5d, 0x42, 0x28, 0xef, 0xcb, 0x9b, + 0x10, 0x7a, 0x19, 0xbf, 0x72, 0xa3, 0x4a, 0xb9, + 0x56, 0x83, 0x39, 0xa6, 0xb2, 0xcd, 0x48, 0x85, + 0xf9, 0xcc, 0x72, 0x88, 0xb3, 0x5a, 0x9b, 0x45, + 0xb2, 0xd3, 0x66, 0x2d, 0x24, 0x51, 0x68, 0x91, + 0x9d, 0x47, 0x6a, 0xb3, 0x9a, 0x60, 0xb3, 0xcd, + 0x6b, 0x43, 0x96, 0x21, 0xa0, 0x65, 0x43, 0xde, + 0x4f, 0x6e, 0xb5, 0x81, 0x50, 0x7e, 0xca, 0x4b, + 0xdb, 0x30, 0xf2, 0xcb, 0x28, 0x3b, 0x19, 0x6a, + 0x0a, 0xfa, 0x05, 0x5e, 0x61, 0xde, 0x76, 0x7e, + 0xdf, 0xd9, 0xa9, 0x1b, 0xd0, 0x8a, 0xb5, 0x04, + 0x51, 0xf5, 0x66, 0xa2, 0x32, 0x21, 0xb2, 0xa9, + 0x40, 0x78, 0x60, 0x9d, 0xdc, 0x45, 0xbe, 0xb4, + 0x3a, 0xba, 0xd1, 0xec, 0x31, 0x53, 0x24, 0x22, + 0x70, 0x99, 0xda, 0xc8, 0x17, 0x04, 0x87, 0x2c, + 0x89, 0x86, 0x24, 0xec, 0x52, 0x12, 0x6a, 0x51, + 0x1e, 0x2a, 0x5e, 0x96, 0xfb, 0xac, 0x95, 0x4a, + 0x1a, 0x06, 0x8f, 0xdf, 0xa7, 0x26, 0xeb, 0x6c, + 0x79, 0x4a, 0x77, 0xea, 0xb3, 0xb1, 0x3a, 0x19, + 0xe6, 0x5e, 0xe2, 0x26, 0x1b, 0x85, 0x3c, 0x9b, + 0x1d, 0x05, 0x1d, 0xbe, 0x5c, 0x25, 0x7f, 0x45, + 0x4c, 0x09, 0x4c, 0xc1, 0x47, 0xa5, 0x44, 0xfc, + 0x04, 0x2b, 0xad, 0x53, 0xac, 0x57, 0x22, 0x54, + 0x13, 0x7c, 0xc9, 0x96, 0x44, 0xda, 0x74, 0x95, + 0x6e, 0x8c, 0xe6, 0x6a, 0x05, 0x05, 0xf3, 0x8c, + 0x81, 0xaf, 0xbc, 0xb1, 0x91, 0xe7, 0xfd, 0x81, + 0x3f, 0x47, 0xc2, 0x6f, 0x0d, 0x62, 0xf6, 0x6e, +}; + +/* + * IV method encblkno8, blkno 2. + */ +static const uint8_t aes_cbc_256_encblkno8_vec2_ctxt[SECSIZE] = { + 0x5a, 0x24, 0xfd, 0xee, 0x9a, 0x44, 0xfb, 0xac, + 0x3e, 0x46, 0x53, 0x95, 0x9e, 0xeb, 0x1f, 0xd9, + 0xfd, 0xc6, 0x4f, 0xae, 0x0b, 0xc8, 0xf2, 0xbd, + 0x77, 0x16, 0x7a, 0x2e, 0x8e, 0xec, 0x7a, 0x53, + 0xf4, 0xe0, 0x34, 0xba, 0x6e, 0xfa, 0xc4, 0x69, + 0xd7, 0x50, 0x13, 0x03, 0xfb, 0xb9, 0x66, 0x96, + 0xd4, 0x21, 0x67, 0xcc, 0x4c, 0x4d, 0x10, 0x2f, + 0x17, 0xeb, 0x41, 0xf4, 0x65, 0x80, 0x0b, 0x57, + 0x2d, 0xdf, 0xcf, 0x9f, 0xb9, 0xd8, 0x53, 0x36, + 0xbc, 0x1d, 0x9a, 0xe3, 0x17, 0xe7, 0x08, 0x23, + 0xb3, 0x60, 0xfe, 0xdf, 0x24, 0x06, 0xc5, 0x86, + 0x74, 0x89, 0xa3, 0xb2, 0xfc, 0x4a, 0x57, 0xf5, + 0xa6, 0x96, 0xfb, 0x56, 0xf0, 0xf4, 0xdc, 0xdc, + 0xb8, 0x53, 0x5f, 0xb2, 0xb0, 0x8d, 0x2d, 0x90, + 0x3d, 0x78, 0x4d, 0x42, 0x3a, 0x74, 0xa4, 0x8e, + 0x41, 0x7c, 0x2a, 0xff, 0xe4, 0x57, 0x1c, 0x9d, + 0x94, 0xc5, 0x5d, 0xd8, 0x8b, 0x88, 0x48, 0x15, + 0x16, 0x8a, 0xf3, 0x07, 0x3a, 0xee, 0x65, 0x24, + 0xbc, 0x7f, 0x58, 0xad, 0xed, 0xf2, 0xbd, 0x18, + 0x88, 0x1a, 0x80, 0x6e, 0xb7, 0x93, 0xe0, 0x45, + 0x04, 0xb0, 0xfc, 0xf9, 0x48, 0x76, 0xaf, 0xec, + 0x08, 0xca, 0x99, 0x64, 0x85, 0x98, 0x2c, 0xd8, + 0x85, 0x72, 0x32, 0xbe, 0x92, 0x18, 0xdd, 0xab, + 0x20, 0x8f, 0x8e, 0x11, 0xc6, 0x08, 0xf9, 0x8b, + 0xaf, 0x5f, 0xa9, 0xe5, 0x11, 0xc7, 0x45, 0x91, + 0x6e, 0x47, 0xaa, 0x0f, 0x4c, 0xf4, 0xc1, 0xb0, + 0x75, 0x4c, 0xba, 0x1d, 0xb3, 0x33, 0xf7, 0x47, + 0xbe, 0x94, 0x0b, 0x2e, 0xfa, 0x38, 0x5e, 0x5f, + 0x0a, 0xc2, 0x0c, 0x4e, 0x72, 0x29, 0x16, 0xc1, + 0x82, 0x70, 0xd4, 0xd3, 0x1b, 0x25, 0xbe, 0x0d, + 0x6b, 0x0a, 0x13, 0x9f, 0x4d, 0x3d, 0x7b, 0x10, + 0x9f, 0x93, 0x43, 0x50, 0xd1, 0x17, 0x08, 0x77, + 0x23, 0x58, 0x35, 0x41, 0x23, 0xf6, 0x9c, 0x6f, + 0x2e, 0x81, 0x6e, 0x75, 0x9b, 0x9f, 0x37, 0x4f, + 0xb7, 0xa1, 0xce, 0xde, 0x0c, 0x74, 0x99, 0x31, + 0x0e, 0x27, 0x42, 0x99, 0xdd, 0x93, 0x03, 0x6b, + 0x44, 0x22, 0xd4, 0xc8, 0x67, 0xb5, 0xb2, 0x4d, + 0x11, 0x2e, 0x80, 0x09, 0xa2, 0x5b, 0xcf, 0x0c, + 0xff, 0xfa, 0x51, 0xe5, 0x9b, 0xdd, 0x11, 0xa1, + 0x17, 0x04, 0x9e, 0xc8, 0xd8, 0x1d, 0xc1, 0x5c, + 0xc3, 0xde, 0x83, 0x77, 0xa3, 0xec, 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xf9, 0xf8, 0xa7, 0x3f, 0x85, 0xa1, 0xa4, +}; + +/* + * IV method encblkno8, blkno 3. + */ +static const uint8_t aes_cbc_256_encblkno8_vec3_ctxt[SECSIZE] = { + 0x83, 0x77, 0xd8, 0xa8, 0x6a, 0x36, 0x41, 0x72, + 0xb6, 0x03, 0x4e, 0x5e, 0x39, 0x36, 0xe3, 0xf5, + 0xd0, 0x1b, 0x0d, 0x97, 0x78, 0x46, 0xee, 0xfd, + 0x34, 0x34, 0x16, 0xa0, 0x44, 0xcf, 0x0b, 0xdc, + 0xfb, 0x82, 0x98, 0xa2, 0x79, 0xc2, 0xe7, 0x1c, + 0x43, 0x43, 0x4c, 0x7f, 0xe7, 0xa6, 0xe6, 0x10, + 0x9e, 0x65, 0xb2, 0x09, 0xc7, 0x5f, 0xaa, 0xb7, + 0xb8, 0xad, 0x83, 0xd5, 0x9e, 0xd1, 0xb2, 0xce, + 0x4b, 0xa4, 0x5d, 0xbc, 0xd6, 0xf6, 0x0a, 0xe7, + 0x1b, 0xe9, 0x86, 0xbc, 0x72, 0xcc, 0x6f, 0xcc, + 0xf2, 0xde, 0x08, 0x48, 0xa2, 0x20, 0x31, 0x6a, + 0xdd, 0xbe, 0xc5, 0x36, 0x55, 0xff, 0xce, 0xfa, + 0xdf, 0x60, 0x26, 0x77, 0x7f, 0xd0, 0xfa, 0xd7, + 0x76, 0x70, 0x14, 0x11, 0xbf, 0x57, 0xc2, 0xdd, + 0x5f, 0xd3, 0x50, 0x49, 0xf8, 0xd1, 0xa7, 0xe2, + 0x8b, 0x89, 0xa0, 0xbc, 0x44, 0x42, 0x45, 0x10, + 0xfe, 0x66, 0x3d, 0x56, 0x09, 0x21, 0x7c, 0x49, + 0x30, 0xde, 0xe2, 0x4b, 0x26, 0x65, 0x8a, 0xe4, + 0x79, 0x08, 0x3a, 0xca, 0x36, 0x4f, 0x97, 0x3c, + 0xe4, 0x6a, 0xc3, 0xdb, 0xce, 0xac, 0x78, 0x76, + 0x25, 0x81, 0x7a, 0x01, 0x7b, 0xd8, 0xf1, 0x00, + 0x8d, 0x2e, 0xb7, 0x98, 0x3c, 0x86, 0x20, 0xa3, + 0x4c, 0x24, 0x2a, 0x78, 0x3a, 0x8d, 0xeb, 0xcd, + 0xae, 0xe1, 0x32, 0xf8, 0x21, 0x37, 0x30, 0x27, + 0xe1, 0xf3, 0x14, 0x60, 0x96, 0x77, 0x37, 0x50, + 0xa2, 0x92, 0xae, 0xe5, 0xd8, 0xea, 0x1a, 0x7e, + 0xa3, 0xd1, 0x04, 0x17, 0x03, 0x51, 0x2f, 0x21, + 0xa7, 0x00, 0x23, 0xb3, 0x24, 0xd8, 0x7d, 0xb7, + 0x4c, 0x51, 0xb1, 0xaf, 0xb0, 0x64, 0xe4, 0x62, + 0x91, 0x4c, 0xd5, 0x4b, 0xe8, 0xfb, 0x95, 0x61, + 0xa4, 0x6f, 0xf8, 0xb8, 0xea, 0xa9, 0xb2, 0x10, + 0xd3, 0x96, 0xcb, 0x1c, 0xdc, 0x86, 0x43, 0x26, + 0x2d, 0x39, 0xc2, 0xa7, 0x69, 0xfa, 0x8f, 0x3a, + 0xe7, 0xe0, 0x27, 0xbe, 0xc2, 0xe8, 0xd5, 0x05, + 0xbe, 0x5a, 0x96, 0xdc, 0x86, 0xcd, 0x93, 0x75, + 0x1b, 0x61, 0x40, 0x8c, 0x60, 0x64, 0x79, 0x85, + 0x6c, 0xed, 0x39, 0x72, 0x26, 0x69, 0xba, 0xb2, + 0xff, 0xa8, 0x68, 0x29, 0x03, 0xf7, 0x26, 0xe7, + 0x0f, 0x53, 0x1b, 0x5b, 0x37, 0x21, 0x68, 0x70, + 0x1c, 0x39, 0x7f, 0x5b, 0x31, 0xca, 0xde, 0xed, + 0x33, 0x8d, 0xaf, 0xe6, 0x01, 0xd5, 0x72, 0x5f, + 0x46, 0x44, 0x34, 0x1b, 0x4c, 0xd7, 0x75, 0xf0, + 0x47, 0x16, 0x6c, 0xd6, 0x65, 0x3c, 0xd3, 0xc2, + 0xb1, 0x46, 0x7d, 0xd5, 0x5c, 0x48, 0x5b, 0x61, + 0x3e, 0x88, 0xff, 0x24, 0x5c, 0x7b, 0xf7, 0xa9, + 0x44, 0xcb, 0x3b, 0x3e, 0x3b, 0x93, 0x24, 0x46, + 0x7e, 0x34, 0x8d, 0xc4, 0x2b, 0xb7, 0x8e, 0x22, + 0x9e, 0x87, 0x62, 0xca, 0xbc, 0x10, 0x09, 0x4a, + 0x4b, 0x0b, 0xdb, 0x57, 0x9b, 0xa9, 0x3e, 0xa8, + 0x99, 0x59, 0xa0, 0x12, 0xf3, 0xa5, 0xe4, 0x91, + 0xbb, 0xb9, 0x05, 0x8d, 0xcf, 0xb9, 0xcb, 0x36, + 0x97, 0xb2, 0x6a, 0x31, 0x8f, 0xcb, 0xf8, 0x5a, + 0x2f, 0x9e, 0xa1, 0xf9, 0x7a, 0xf4, 0x10, 0x0e, + 0xe7, 0x7f, 0x4c, 0xcb, 0xe3, 0x83, 0x17, 0x39, + 0x34, 0xef, 0x49, 0x35, 0x68, 0x50, 0x80, 0xf9, + 0xcd, 0x3a, 0x10, 0xf6, 0x71, 0x1a, 0x94, 0xc3, + 0xec, 0xb9, 0x36, 0x84, 0x36, 0xe7, 0x3f, 0x6f, + 0x9b, 0xa9, 0x2b, 0x5c, 0x96, 0x49, 0x26, 0xda, + 0xb3, 0x08, 0x3d, 0x5e, 0x9e, 0x59, 0xdf, 0x0f, + 0xfc, 0xbe, 0xa8, 0x0b, 0xbc, 0xaa, 0x32, 0xf0, + 0xa5, 0x21, 0x50, 0x15, 0x7e, 0x46, 0xb9, 0x76, + 0x09, 0x4e, 0x4b, 0x6f, 0x9f, 0xc7, 0x8c, 0x6d, + 0x80, 0x37, 0xf9, 0xaa, 0xd1, 0x5f, 0x12, 0xb9, + 0xb3, 0x15, 0xe4, 0x96, 0xa1, 0x01, 0xd5, 0xa0, +}; + +const struct testvec aes_cbc_256_8_vectors[] = { + { + .blkno = 0, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_256_encblkno8_vec0_ctxt, + }, + { + .blkno = 1, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_256_encblkno8_vec1_ctxt, + }, + { + .blkno = 2, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_256_encblkno8_vec2_ctxt, + }, + { + .blkno = 3, + .ptxt = aes_cbc_ptxt, + .ctxt = aes_cbc_256_encblkno8_vec3_ctxt, + }, +}; + +/* + * 256 bits key from IEEE 1619/D16, NUL terminated. + */ +static const char aes_xts_256_key[33] = { + 0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45, + 0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26, + 0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93, + 0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95, + 0 +}; + +/* + * 512 bits key from IEEE 1619/D16, NUL terminated. + */ +static const char aes_xts_512_key[65] = { + 0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45, + 0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26, + 0x62, 0x49, 0x77, 0x57, 0x24, 0x70, 0x93, 0x69, + 0x99, 0x59, 0x57, 0x49, 0x66, 0x96, 0x76, 0x27, + 0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93, + 0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95, + 0x02, 0x88, 0x41, 0x97, 0x16, 0x93, 0x99, 0x37, + 0x51, 0x05, 0x82, 0x09, 0x74, 0x94, 0x45, 0x92, + 0 +}; + +/* + * Vector 4 from IEEE 1619/D16, blkno 0. + */ +static const uint8_t aes_xts_256_vec4_ptxt[SECSIZE] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 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, 0xd8, 0xfa, 0x7f, 0x56, 0x00, 0x00, + 0x05, 0x27, 0x9f, 0xa5, 0xd8, 0xb5, 0xe4, 0xad, + 0x40, 0xe7, 0x36, 0xdd, 0xb4, 0xd3, 0x54, 0x12, + 0x32, 0x80, 0x63, 0xfd, 0x2a, 0xab, 0x53, 0xe5, + 0xea, 0x1e, 0x0a, 0x9f, 0x33, 0x25, 0x00, 0xa5, + 0xdf, 0x94, 0x87, 0xd0, 0x7a, 0x5c, 0x92, 0xcc, + 0x51, 0x2c, 0x88, 0x66, 0xc7, 0xe8, 0x60, 0xce, + 0x93, 0xfd, 0xf1, 0x66, 0xa2, 0x49, 0x12, 0xb4, + 0x22, 0x97, 0x61, 0x46, 0xae, 0x20, 0xce, 0x84, + 0x6b, 0xb7, 0xdc, 0x9b, 0xa9, 0x4a, 0x76, 0x7a, + 0xae, 0xf2, 0x0c, 0x0d, 0x61, 0xad, 0x02, 0x65, + 0x5e, 0xa9, 0x2d, 0xc4, 0xc4, 0xe4, 0x1a, 0x89, + 0x52, 0xc6, 0x51, 0xd3, 0x31, 0x74, 0xbe, 0x51, + 0xa1, 0x0c, 0x42, 0x11, 0x10, 0xe6, 0xd8, 0x15, + 0x88, 0xed, 0xe8, 0x21, 0x03, 0xa2, 0x52, 0xd8, + 0xa7, 0x50, 0xe8, 0x76, 0x8d, 0xef, 0xff, 0xed, + 0x91, 0x22, 0x81, 0x0a, 0xae, 0xb9, 0x9f, 0x91, + 0x72, 0xaf, 0x82, 0xb6, 0x04, 0xdc, 0x4b, 0x8e, + 0x51, 0xbc, 0xb0, 0x82, 0x35, 0xa6, 0xf4, 0x34, + 0x13, 0x32, 0xe4, 0xca, 0x60, 0x48, 0x2a, 0x4b, + 0xa1, 0xa0, 0x3b, 0x3e, 0x65, 0x00, 0x8f, 0xc5, + 0xda, 0x76, 0xb7, 0x0b, 0xf1, 0x69, 0x0d, 0xb4, + 0xea, 0xe2, 0x9c, 0x5f, 0x1b, 0xad, 0xd0, 0x3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x77, 0xae, 0x11, 0x9f, 0x7a, + 0x02, 0x3a, 0xb5, 0x8c, 0xca, 0x0a, 0xd7, 0x52, + 0xaf, 0xe6, 0x56, 0xbb, 0x3c, 0x17, 0x25, 0x6a, + 0x9f, 0x6e, 0x9b, 0xf1, 0x9f, 0xdd, 0x5a, 0x38, + 0xfc, 0x82, 0xbb, 0xe8, 0x72, 0xc5, 0x53, 0x9e, + 0xdb, 0x60, 0x9e, 0xf4, 0xf7, 0x9c, 0x20, 0x3e, + 0xbb, 0x14, 0x0f, 0x2e, 0x58, 0x3c, 0xb2, 0xad, + 0x15, 0xb4, 0xaa, 0x5b, 0x65, 0x50, 0x16, 0xa8, + 0x44, 0x92, 0x77, 0xdb, 0xd4, 0x77, 0xef, 0x2c, + 0x8d, 0x6c, 0x01, 0x7d, 0xb7, 0x38, 0xb1, 0x8d, + 0xeb, 0x4a, 0x42, 0x7d, 0x19, 0x23, 0xce, 0x3f, + 0xf2, 0x62, 0x73, 0x57, 0x79, 0xa4, 0x18, 0xf2, + 0x0a, 0x28, 0x2d, 0xf9, 0x20, 0x14, 0x7b, 0xea, + 0xbe, 0x42, 0x1e, 0xe5, 0x31, 0x9d, 0x05, 0x68, +}; + +/* + * Vector 5 from IEEE 1619/D16, blkno 1. + */ +static const uint8_t aes_xts_256_vec5_ptxt[SECSIZE] = { + 0x27, 0xa7, 0x47, 0x9b, 0xef, 0xa1, 0xd4, 0x76, + 0x48, 0x9f, 0x30, 0x8c, 0xd4, 0xcf, 0xa6, 0xe2, + 0xa9, 0x6e, 0x4b, 0xbe, 0x32, 0x08, 0xff, 0x25, + 0x28, 0x7d, 0xd3, 0x81, 0x96, 0x16, 0xe8, 0x9c, + 0xc7, 0x8c, 0xf7, 0xf5, 0xe5, 0x43, 0x44, 0x5f, + 0x83, 0x33, 0xd8, 0xfa, 0x7f, 0x56, 0x00, 0x00, + 0x05, 0x27, 0x9f, 0xa5, 0xd8, 0xb5, 0xe4, 0xad, + 0x40, 0xe7, 0x36, 0xdd, 0xb4, 0xd3, 0x54, 0x12, + 0x32, 0x80, 0x63, 0xfd, 0x2a, 0xab, 0x53, 0xe5, + 0xea, 0x1e, 0x0a, 0x9f, 0x33, 0x25, 0x00, 0xa5, + 0xdf, 0x94, 0x87, 0xd0, 0x7a, 0x5c, 0x92, 0xcc, + 0x51, 0x2c, 0x88, 0x66, 0xc7, 0xe8, 0x60, 0xce, + 0x93, 0xfd, 0xf1, 0x66, 0xa2, 0x49, 0x12, 0xb4, + 0x22, 0x97, 0x61, 0x46, 0xae, 0x20, 0xce, 0x84, + 0x6b, 0xb7, 0xdc, 0x9b, 0xa9, 0x4a, 0x76, 0x7a, + 0xae, 0xf2, 0x0c, 0x0d, 0x61, 0xad, 0x02, 0x65, + 0x5e, 0xa9, 0x2d, 0xc4, 0xc4, 0xe4, 0x1a, 0x89, + 0x52, 0xc6, 0x51, 0xd3, 0x31, 0x74, 0xbe, 0x51, + 0xa1, 0x0c, 0x42, 0x11, 0x10, 0xe6, 0xd8, 0x15, + 0x88, 0xed, 0xe8, 0x21, 0x03, 0xa2, 0x52, 0xd8, + 0xa7, 0x50, 0xe8, 0x76, 0x8d, 0xef, 0xff, 0xed, + 0x91, 0x22, 0x81, 0x0a, 0xae, 0xb9, 0x9f, 0x91, + 0x72, 0xaf, 0x82, 0xb6, 0x04, 0xdc, 0x4b, 0x8e, + 0x51, 0xbc, 0xb0, 0x82, 0x35, 0xa6, 0xf4, 0x34, + 0x13, 0x32, 0xe4, 0xca, 0x60, 0x48, 0x2a, 0x4b, + 0xa1, 0xa0, 0x3b, 0x3e, 0x65, 0x00, 0x8f, 0xc5, + 0xda, 0x76, 0xb7, 0x0b, 0xf1, 0x69, 0x0d, 0xb4, + 0xea, 0xe2, 0x9c, 0x5f, 0x1b, 0xad, 0xd0, 0x3c, + 0x5c, 0xcf, 0x2a, 0x55, 0xd7, 0x05, 0xdd, 0xcd, + 0x86, 0xd4, 0x49, 0x51, 0x1c, 0xeb, 0x7e, 0xc3, +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0x3c, 0x17, 0x25, 0x6a, + 0x9f, 0x6e, 0x9b, 0xf1, 0x9f, 0xdd, 0x5a, 0x38, + 0xfc, 0x82, 0xbb, 0xe8, 0x72, 0xc5, 0x53, 0x9e, + 0xdb, 0x60, 0x9e, 0xf4, 0xf7, 0x9c, 0x20, 0x3e, + 0xbb, 0x14, 0x0f, 0x2e, 0x58, 0x3c, 0xb2, 0xad, + 0x15, 0xb4, 0xaa, 0x5b, 0x65, 0x50, 0x16, 0xa8, + 0x44, 0x92, 0x77, 0xdb, 0xd4, 0x77, 0xef, 0x2c, + 0x8d, 0x6c, 0x01, 0x7d, 0xb7, 0x38, 0xb1, 0x8d, + 0xeb, 0x4a, 0x42, 0x7d, 0x19, 0x23, 0xce, 0x3f, + 0xf2, 0x62, 0x73, 0x57, 0x79, 0xa4, 0x18, 0xf2, + 0x0a, 0x28, 0x2d, 0xf9, 0x20, 0x14, 0x7b, 0xea, + 0xbe, 0x42, 0x1e, 0xe5, 0x31, 0x9d, 0x05, 0x68, +}; + +static const uint8_t aes_xts_256_vec5_ctxt[SECSIZE] = { + 0x26, 0x4d, 0x3c, 0xa8, 0x51, 0x21, 0x94, 0xfe, + 0xc3, 0x12, 0xc8, 0xc9, 0x89, 0x1f, 0x27, 0x9f, + 0xef, 0xdd, 0x60, 0x8d, 0x0c, 0x02, 0x7b, 0x60, + 0x48, 0x3a, 0x3f, 0xa8, 0x11, 0xd6, 0x5e, 0xe5, + 0x9d, 0x52, 0xd9, 0xe4, 0x0e, 0xc5, 0x67, 0x2d, + 0x81, 0x53, 0x2b, 0x38, 0xb6, 0xb0, 0x89, 0xce, + 0x95, 0x1f, 0x0f, 0x9c, 0x35, 0x59, 0x0b, 0x8b, + 0x97, 0x8d, 0x17, 0x52, 0x13, 0xf3, 0x29, 0xbb, + 0x1c, 0x2f, 0xd3, 0x0f, 0x2f, 0x7f, 0x30, 0x49, + 0x2a, 0x61, 0xa5, 0x32, 0xa7, 0x9f, 0x51, 0xd3, + 0x6f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77, 0x9a, 0x0d, 0xf5, + 0x0e, 0xdc, 0xde, 0x45, 0x31, 0xda, 0x07, 0xb0, + 0x99, 0xc6, 0x38, 0xe8, 0x3a, 0x75, 0x59, 0x44, + 0xdf, 0x2a, 0xef, 0x1a, 0xa3, 0x17, 0x52, 0xfd, + 0x32, 0x3d, 0xcb, 0x71, 0x0f, 0xb4, 0xbf, 0xbb, + 0x9d, 0x22, 0xb9, 0x25, 0xbc, 0x35, 0x77, 0xe1, + 0xb8, 0x94, 0x9e, 0x72, 0x9a, 0x90, 0xbb, 0xaf, + 0xea, 0xcf, 0x7f, 0x78, 0x79, 0xe7, 0xb1, 0x14, + 0x7e, 0x28, 0xba, 0x0b, 0xae, 0x94, 0x0d, 0xb7, + 0x95, 0xa6, 0x1b, 0x15, 0xec, 0xf4, 0xdf, 0x8d, + 0xb0, 0x7b, 0x82, 0x4b, 0xb0, 0x62, 0x80, 0x2c, + 0xc9, 0x8a, 0x95, 0x45, 0xbb, 0x2a, 0xae, 0xed, + 0x77, 0xcb, 0x3f, 0xc6, 0xdb, 0x15, 0xdc, 0xd7, + 0xd8, 0x0d, 0x7d, 0x5b, 0xc4, 0x06, 0xc4, 0x97, + 0x0a, 0x34, 0x78, 0xad, 0xa8, 0x89, 0x9b, 0x32, + 0x91, 0x98, 0xeb, 0x61, 0xc1, 0x93, 0xfb, 0x62, + 0x75, 0xaa, 0x8c, 0xa3, 0x40, 0x34, 0x4a, 0x75, + 0xa8, 0x62, 0xae, 0xbe, 0x92, 0xee, 0xe1, 0xce, + 0x03, 0x2f, 0xd9, 0x50, 0xb4, 0x7d, 0x77, 0x04, + 0xa3, 0x87, 0x69, 0x23, 0xb4, 0xad, 0x62, 0x84, + 0x4b, 0xf4, 0xa0, 0x9c, 0x4d, 0xbe, 0x8b, 0x43, + 0x97, 0x18, 0x4b, 0x74, 0x71, 0x36, 0x0c, 0x95, + 0x64, 0x88, 0x0a, 0xed, 0xdd, 0xb9, 0xba, 0xa4, + 0xaf, 0x2e, 0x75, 0x39, 0x4b, 0x08, 0xcd, 0x32, + 0xff, 0x47, 0x9c, 0x57, 0xa0, 0x7d, 0x3e, 0xab, + 0x5d, 0x54, 0xde, 0x5f, 0x97, 0x38, 0xb8, 0xd2, + 0x7f, 0x27, 0xa9, 0xf0, 0xab, 0x11, 0x79, 0x9d, + 0x7b, 0x7f, 0xfe, 0xfb, 0x27, 0x04, 0xc9, 0x5c, + 0x6a, 0xd1, 0x2c, 0x39, 0xf1, 0xe8, 0x67, 0xa4, + 0xb7, 0xb1, 0xd7, 0x81, 0x8a, 0x4b, 0x75, 0x3d, + 0xfd, 0x2a, 0x89, 0xcc, 0xb4, 0x5e, 0x00, 0x1a, + 0x03, 0xa8, 0x67, 0xb1, 0x87, 0xf2, 0x25, 0xdd, +}; + +/* + * Vector 6 from IEEE 1619/D16, blkno 2. + */ +static const uint8_t aes_xts_256_vec6_ptxt[SECSIZE] = { + 0x26, 0x4d, 0x3c, 0xa8, 0x51, 0x21, 0x94, 0xfe, + 0xc3, 0x12, 0xc8, 0xc9, 0x89, 0x1f, 0x27, 0x9f, + 0xef, 0xdd, 0x60, 0x8d, 0x0c, 0x02, 0x7b, 0x60, + 0x48, 0x3a, 0x3f, 0xa8, 0x11, 0xd6, 0x5e, 0xe5, + 0x9d, 0x52, 0xd9, 0xe4, 0x0e, 0xc5, 0x67, 0x2d, + 0x81, 0x53, 0x2b, 0x38, 0xb6, 0xb0, 0x89, 0xce, + 0x95, 0x1f, 0x0f, 0x9c, 0x35, 0x59, 0x0b, 0x8b, + 0x97, 0x8d, 0x17, 0x52, 0x13, 0xf3, 0x29, 0xbb, + 0x1c, 0x2f, 0xd3, 0x0f, 0x2f, 0x7f, 0x30, 0x49, + 0x2a, 0x61, 0xa5, 0x32, 0xa7, 0x9f, 0x51, 0xd3, + 0x6f, 0x5e, 0x31, 0xa7, 0xc9, 0xa1, 0x2c, 0x28, + 0x60, 0x82, 0xff, 0x7d, 0x23, 0x94, 0xd1, 0x8f, + 0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0x3a, 0x75, 0x59, 0x44, + 0xdf, 0x2a, 0xef, 0x1a, 0xa3, 0x17, 0x52, 0xfd, + 0x32, 0x3d, 0xcb, 0x71, 0x0f, 0xb4, 0xbf, 0xbb, + 0x9d, 0x22, 0xb9, 0x25, 0xbc, 0x35, 0x77, 0xe1, + 0xb8, 0x94, 0x9e, 0x72, 0x9a, 0x90, 0xbb, 0xaf, + 0xea, 0xcf, 0x7f, 0x78, 0x79, 0xe7, 0xb1, 0x14, + 0x7e, 0x28, 0xba, 0x0b, 0xae, 0x94, 0x0d, 0xb7, + 0x95, 0xa6, 0x1b, 0x15, 0xec, 0xf4, 0xdf, 0x8d, + 0xb0, 0x7b, 0x82, 0x4b, 0xb0, 0x62, 0x80, 0x2c, + 0xc9, 0x8a, 0x95, 0x45, 0xbb, 0x2a, 0xae, 0xed, + 0x77, 0xcb, 0x3f, 0xc6, 0xdb, 0x15, 0xdc, 0xd7, + 0xd8, 0x0d, 0x7d, 0x5b, 0xc4, 0x06, 0xc4, 0x97, + 0x0a, 0x34, 0x78, 0xad, 0xa8, 0x89, 0x9b, 0x32, + 0x91, 0x98, 0xeb, 0x61, 0xc1, 0x93, 0xfb, 0x62, + 0x75, 0xaa, 0x8c, 0xa3, 0x40, 0x34, 0x4a, 0x75, + 0xa8, 0x62, 0xae, 0xbe, 0x92, 0xee, 0xe1, 0xce, + 0x03, 0x2f, 0xd9, 0x50, 0xb4, 0x7d, 0x77, 0x04, + 0xa3, 0x87, 0x69, 0x23, 0xb4, 0xad, 0x62, 0x84, + 0x4b, 0xf4, 0xa0, 0x9c, 0x4d, 0xbe, 0x8b, 0x43, + 0x97, 0x18, 0x4b, 0x74, 0x71, 0x36, 0x0c, 0x95, + 0x64, 0x88, 0x0a, 0xed, 0xdd, 0xb9, 0xba, 0xa4, + 0xaf, 0x2e, 0x75, 0x39, 0x4b, 0x08, 0xcd, 0x32, + 0xff, 0x47, 0x9c, 0x57, 0xa0, 0x7d, 0x3e, 0xab, + 0x5d, 0x54, 0xde, 0x5f, 0x97, 0x38, 0xb8, 0xd2, + 0x7f, 0x27, 0xa9, 0xf0, 0xab, 0x11, 0x79, 0x9d, + 0x7b, 0x7f, 0xfe, 0xfb, 0x27, 0x04, 0xc9, 0x5c, + 0x6a, 0xd1, 0x2c, 0x39, 0xf1, 0xe8, 0x67, 0xa4, + 0xb7, 0xb1, 0xd7, 0x81, 0x8a, 0x4b, 0x75, 0x3d, + 0xfd, 0x2a, 0x89, 0xcc, 0xb4, 0x5e, 0x00, 0x1a, + 0x03, 0xa8, 0x67, 0xb1, 0x87, 0xf2, 0x25, 0xdd, +}; + +static const uint8_t aes_xts_256_vec6_ctxt[SECSIZE] = { + 0xfa, 0x76, 0x2a, 0x36, 0x80, 0xb7, 0x60, 0x07, + 0x92, 0x8e, 0xd4, 0xa4, 0xf4, 0x9a, 0x94, 0x56, + 0x03, 0x1b, 0x70, 0x47, 0x82, 0xe6, 0x5e, 0x16, + 0xce, 0xcb, 0x54, 0xed, 0x7d, 0x01, 0x7b, 0x5e, + 0x18, 0xab, 0xd6, 0x7b, 0x33, 0x8e, 0x81, 0x07, + 0x8f, 0x21, 0xed, 0xb7, 0x86, 0x8d, 0x90, 0x1e, + 0xbe, 0x9c, 0x73, 0x1a, 0x7c, 0x18, 0xb5, 0xe6, + 0xde, 0xc1, 0xd6, 0xa7, 0x2e, 0x07, 0x8a, 0xc9, + 0xa4, 0x26, 0x2f, 0x86, 0x0b, 0xee, 0xfa, 0x14, + 0xf4, 0xe8, 0x21, 0x01, 0x82, 0x72, 0xe4, 0x11, + 0xa9, 0x51, 0x50, 0x2b, 0x6e, 0x79, 0x06, 0x6e, + 0x84, 0x25, 0x2c, 0x33, 0x46, 0xf3, 0xaa, 0x62, + 0x34, 0x43, 0x51, 0xa2, 0x91, 0xd4, 0xbe, 0xdc, + 0x7a, 0x07, 0x61, 0x8b, 0xde, 0xa2, 0xaf, 0x63, + 0x14, 0x5c, 0xc7, 0xa4, 0xb8, 0xd4, 0x07, 0x06, + 0x91, 0xae, 0x89, 0x0c, 0xd6, 0x57, 0x33, 0xe7, + 0x94, 0x6e, 0x90, 0x21, 0xa1, 0xdf, 0xfc, 0x4c, + 0x59, 0xf1, 0x59, 0x42, 0x5e, 0xe6, 0xd5, 0x0c, + 0xa9, 0xb1, 0x35, 0xfa, 0x61, 0x62, 0xce, 0xa1, + 0x8a, 0x93, 0x98, 0x38, 0xdc, 0x00, 0x0f, 0xb3, + 0x86, 0xfa, 0xd0, 0x86, 0xac, 0xce, 0x5a, 0xc0, + 0x7c, 0xb2, 0xec, 0xe7, 0xfd, 0x58, 0x0b, 0x00, + 0xcf, 0xa5, 0xe9, 0x85, 0x89, 0x63, 0x1d, 0xc2, + 0x5e, 0x8e, 0x2a, 0x3d, 0xaf, 0x2f, 0xfd, 0xec, + 0x26, 0x53, 0x16, 0x59, 0x91, 0x2c, 0x9d, 0x8f, + 0x7a, 0x15, 0xe5, 0x86, 0x5e, 0xa8, 0xfb, 0x58, + 0x16, 0xd6, 0x20, 0x70, 0x52, 0xbd, 0x71, 0x28, + 0xcd, 0x74, 0x3c, 0x12, 0xc8, 0x11, 0x87, 0x91, + 0xa4, 0x73, 0x68, 0x11, 0x93, 0x5e, 0xb9, 0x82, + 0xa5, 0x32, 0x34, 0x9e, 0x31, 0xdd, 0x40, 0x1e, + 0x0b, 0x66, 0x0a, 0x56, 0x8c, 0xb1, 0xa4, 0x71, + 0x1f, 0x55, 0x2f, 0x55, 0xde, 0xd5, 0x9f, 0x1f, + 0x15, 0xbf, 0x71, 0x96, 0xb3, 0xca, 0x12, 0xa9, + 0x1e, 0x48, 0x8e, 0xf5, 0x9d, 0x64, 0xf3, 0xa0, + 0x2b, 0xf4, 0x52, 0x39, 0x49, 0x9a, 0xc6, 0x17, + 0x6a, 0xe3, 0x21, 0xc4, 0xa2, 0x11, 0xec, 0x54, + 0x53, 0x65, 0x97, 0x1c, 0x5d, 0x3f, 0x4f, 0x09, + 0xd4, 0xeb, 0x13, 0x9b, 0xfd, 0xf2, 0x07, 0x3d, + 0x33, 0x18, 0x0b, 0x21, 0x00, 0x2b, 0x65, 0xcc, + 0x98, 0x65, 0xe7, 0x6c, 0xb2, 0x4c, 0xd9, 0x2c, + 0x87, 0x4c, 0x24, 0xc1, 0x83, 0x50, 0x39, 0x9a, + 0x93, 0x6a, 0xb3, 0x63, 0x70, 0x79, 0x29, 0x5d, + 0x76, 0xc4, 0x17, 0x77, 0x6b, 0x94, 0xef, 0xce, + 0x3a, 0x0e, 0xf7, 0x20, 0x6b, 0x15, 0x11, 0x05, + 0x19, 0x65, 0x5c, 0x95, 0x6c, 0xbd, 0x8b, 0x24, + 0x89, 0x40, 0x5e, 0xe2, 0xb0, 0x9a, 0x6b, 0x6e, + 0xeb, 0xe0, 0xc5, 0x37, 0x90, 0xa1, 0x2a, 0x89, + 0x98, 0x37, 0x8b, 0x33, 0xa5, 0xb7, 0x11, 0x59, + 0x62, 0x5f, 0x4b, 0xa4, 0x9d, 0x2a, 0x2f, 0xdb, + 0xa5, 0x9f, 0xbf, 0x08, 0x97, 0xbc, 0x7a, 0xab, + 0xd8, 0xd7, 0x07, 0xdc, 0x14, 0x0a, 0x80, 0xf0, + 0xf3, 0x09, 0xf8, 0x35, 0xd3, 0xda, 0x54, 0xab, + 0x58, 0x4e, 0x50, 0x1d, 0xfa, 0x0e, 0xe9, 0x77, + 0xfe, 0xc5, 0x43, 0xf7, 0x41, 0x86, 0xa8, 0x02, + 0xb9, 0xa3, 0x7a, 0xdb, 0x3e, 0x82, 0x91, 0xec, + 0xa0, 0x4d, 0x66, 0x52, 0x0d, 0x22, 0x9e, 0x60, + 0x40, 0x1e, 0x72, 0x82, 0xbe, 0xf4, 0x86, 0xae, + 0x05, 0x9a, 0xa7, 0x06, 0x96, 0xe0, 0xe3, 0x05, + 0xd7, 0x77, 0x14, 0x0a, 0x7a, 0x88, 0x3e, 0xcd, + 0xcb, 0x69, 0xb9, 0xff, 0x93, 0x8e, 0x8a, 0x42, + 0x31, 0x86, 0x4c, 0x69, 0xca, 0x2c, 0x20, 0x43, + 0xbe, 0xd0, 0x07, 0xff, 0x3e, 0x60, 0x5e, 0x01, + 0x4b, 0xcf, 0x51, 0x81, 0x38, 0xdc, 0x3a, 0x25, + 0xc5, 0xe2, 0x36, 0x17, 0x1a, 0x2d, 0x01, 0xd6, +}; + +/* + * Vector 7 from IEEE 1619/D16, blkno 0xfd. + */ +static const uint8_t aes_xts_256_vec7_ptxt[SECSIZE] = { + 0x8e, 0x41, 0xb7, 0x8c, 0x39, 0x0b, 0x5a, 0xf9, + 0xd7, 0x58, 0xbb, 0x21, 0x4a, 0x67, 0xe9, 0xf6, + 0xbf, 0x77, 0x27, 0xb0, 0x9a, 0xc6, 0x12, 0x40, + 0x84, 0xc3, 0x76, 0x11, 0x39, 0x8f, 0xa4, 0x5d, + 0xaa, 0xd9, 0x48, 0x68, 0x60, 0x0e, 0xd3, 0x91, + 0xfb, 0x1a, 0xcd, 0x48, 0x57, 0xa9, 0x5b, 0x46, + 0x6e, 0x62, 0xef, 0x9f, 0x4b, 0x37, 0x72, 0x44, + 0xd1, 0xc1, 0x52, 0xe7, 0xb3, 0x0d, 0x73, 0x1a, + 0xad, 0x30, 0xc7, 0x16, 0xd2, 0x14, 0xb7, 0x07, + 0xae, 0xd9, 0x9e, 0xb5, 0xb5, 0xe5, 0x80, 0xb3, + 0xe8, 0x87, 0xcf, 0x74, 0x97, 0x46, 0x56, 0x51, + 0xd4, 0xb6, 0x0e, 0x60, 0x42, 0x05, 0x1d, 0xa3, + 0x69, 0x3c, 0x3b, 0x78, 0xc1, 0x44, 0x89, 0x54, + 0x3b, 0xe8, 0xb6, 0xad, 0x0b, 0xa6, 0x29, 0x56, + 0x5b, 0xba, 0x20, 0x23, 0x13, 0xba, 0x7b, 0x0d, + 0x0c, 0x94, 0xa3, 0x25, 0x2b, 0x67, 0x6f, 0x46, + 0xcc, 0x02, 0xce, 0x0f, 0x8a, 0x7d, 0x34, 0xc0, + 0xed, 0x22, 0x91, 0x29, 0x67, 0x3c, 0x1f, 0x61, + 0xae, 0xd5, 0x79, 0xd0, 0x8a, 0x92, 0x03, 0xa2, + 0x5a, 0xac, 0x3a, 0x77, 0xe9, 0xdb, 0x60, 0x26, + 0x79, 0x96, 0xdb, 0x38, 0xdf, 0x63, 0x73, 0x56, + 0xd9, 0xdc, 0xd1, 0x63, 0x2e, 0x36, 0x99, 0x39, + 0xf2, 0xa2, 0x9d, 0x89, 0x34, 0x5c, 0x66, 0xe0, + 0x50, 0x66, 0xf1, 0xa3, 0x67, 0x7a, 0xef, 0x18, + 0xde, 0xa4, 0x11, 0x3f, 0xae, 0xb6, 0x29, 0xe4, + 0x67, 0x21, 0xa6, 0x6d, 0x0a, 0x7e, 0x78, 0x5d, + 0x3e, 0x29, 0xaf, 0x25, 0x94, 0xeb, 0x67, 0xdf, + 0xa9, 0x82, 0xaf, 0xfe, 0x0a, 0xac, 0x05, 0x8f, + 0x6e, 0x15, 0x86, 0x42, 0x69, 0xb1, 0x35, 0x41, + 0x82, 0x61, 0xfc, 0x3a, 0xfb, 0x08, 0x94, 0x72, + 0xcf, 0x68, 0xc4, 0x5d, 0xd7, 0xf2, 0x31, 0xc6, + 0x24, 0x9b, 0xa0, 0x25, 0x5e, 0x1e, 0x03, 0x38, + 0x33, 0xfc, 0x4d, 0x00, 0xa3, 0xfe, 0x02, 0x13, + 0x2d, 0x7b, 0xc3, 0x87, 0x36, 0x14, 0xb8, 0xae, + 0xe3, 0x42, 0x73, 0x58, 0x1e, 0xa0, 0x32, 0x5c, + 0x81, 0xf0, 0x27, 0x0a, 0xff, 0xa1, 0x36, 0x41, + 0xd0, 0x52, 0xd3, 0x6f, 0x07, 0x57, 0xd4, 0x84, + 0x01, 0x43, 0x54, 0xd0, 0x2d, 0x68, 0x83, 0xca, + 0x15, 0xc2, 0x4d, 0x8c, 0x39, 0x56, 0xb1, 0xbd, + 0x02, 0x7b, 0xcf, 0x41, 0xf1, 0x51, 0xfd, 0x80, + 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35, 0x55, 0xfd, 0x42, 0x4e, 0xed, + 0xd6, 0x7e, 0x18, 0xa1, 0x80, 0x94, 0xf8, 0x88, +}; + +static const uint8_t aes_xts_256_vec7_ctxt[SECSIZE] = { + 0xd5, 0x5f, 0x68, 0x4f, 0x81, 0xf4, 0x42, 0x6e, + 0x9f, 0xde, 0x92, 0xa5, 0xff, 0x02, 0xdf, 0x2a, + 0xc8, 0x96, 0xaf, 0x63, 0x96, 0x28, 0x88, 0xa9, + 0x79, 0x10, 0xc1, 0x37, 0x9e, 0x20, 0xb0, 0xa3, + 0xb1, 0xdb, 0x61, 0x3f, 0xb7, 0xfe, 0x2e, 0x07, + 0x00, 0x43, 0x29, 0xea, 0x5c, 0x22, 0xbf, 0xd3, + 0x3e, 0x3d, 0xbe, 0x4c, 0xf5, 0x8c, 0xc6, 0x08, + 0xc2, 0xc2, 0x6c, 0x19, 0xa2, 0xe2, 0xfe, 0x22, + 0xf9, 0x87, 0x32, 0xc2, 0xb5, 0xcb, 0x84, 0x4c, + 0xc6, 0xc0, 0x70, 0x2d, 0x91, 0xe1, 0xd5, 0x0f, + 0xc4, 0x38, 0x2a, 0x7e, 0xba, 0x56, 0x35, 0xcd, + 0x60, 0x24, 0x32, 0xa2, 0x30, 0x6a, 0xc4, 0xce, + 0x82, 0xf8, 0xd7, 0x0c, 0x8d, 0x9b, 0xc1, 0x5f, + 0x91, 0x8f, 0xe7, 0x1e, 0x74, 0xc6, 0x22, 0xd5, + 0xcf, 0x71, 0x17, 0x8b, 0xf6, 0xe0, 0xb9, 0xcc, + 0x9f, 0x2b, 0x41, 0xdd, 0x8d, 0xbe, 0x44, 0x1c, + 0x41, 0xcd, 0x0c, 0x73, 0xa6, 0xdc, 0x47, 0xa3, + 0x48, 0xf6, 0x70, 0x2f, 0x9d, 0x0e, 0x9b, 0x1b, + 0x14, 0x31, 0xe9, 0x48, 0xe2, 0x99, 0xb9, 0xec, + 0x22, 0x72, 0xab, 0x2c, 0x5f, 0x0c, 0x7b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cc, 0xec, 0x1a, 0x32, 0x19, 0x54, + 0x88, 0x6b, 0x7a, 0x12, 0x99, 0xfa, 0xae, 0xec, + 0xae, 0x35, 0xc6, 0xea, 0xac, 0xa7, 0x53, 0xb0, + 0x41, 0xb5, 0xe5, 0xf0, 0x93, 0xbf, 0x83, 0x39, + 0x7f, 0xd2, 0x1d, 0xd6, 0xb3, 0x01, 0x20, 0x66, + 0xfc, 0xc0, 0x58, 0xcc, 0x32, 0xc3, 0xb0, 0x9d, + 0x75, 0x62, 0xde, 0xe2, 0x95, 0x09, 0xb5, 0x83, + 0x93, 0x92, 0xc9, 0xff, 0x05, 0xf5, 0x1f, 0x31, + 0x66, 0xaa, 0xac, 0x4a, 0xc5, 0xf2, 0x38, 0x03, + 0x8a, 0x30, 0x45, 0xe6, 0xf7, 0x2e, 0x48, 0xef, + 0x0f, 0xe8, 0xbc, 0x67, 0x5e, 0x82, 0xc3, 0x18, + 0xa2, 0x68, 0xe4, 0x39, 0x70, 0x27, 0x1b, 0xf1, + 0x19, 0xb8, 0x1b, 0xf6, 0xa9, 0x82, 0x74, 0x65, + 0x54, 0xf8, 0x4e, 0x72, 0xb9, 0xf0, 0x02, 0x80, + 0xa3, 0x20, 0xa0, 0x81, 0x42, 0x92, 0x3c, 0x23, + 0xc8, 0x83, 0x42, 0x3f, 0xf9, 0x49, 0x82, 0x7f, + 0x29, 0xbb, 0xac, 0xdc, 0x1c, 0xcd, 0xb0, 0x49, + 0x38, 0xce, 0x60, 0x98, 0xc9, 0x5b, 0xa6, 0xb3, + 0x25, 0x28, 0xf4, 0xef, 0x78, 0xee, 0xd7, 0x78, + 0xb2, 0xe1, 0x22, 0xdd, 0xfd, 0x1c, 0xbd, 0xd1, + 0x1d, 0x1c, 0x0a, 0x67, 0x83, 0xe0, 0x11, 0xfc, + 0x53, 0x6d, 0x63, 0xd0, 0x53, 0x26, 0x06, 0x37, +}; + +/* + * Vector 8 from IEEE 1619/D16, blkno 0xfe. + */ +static const uint8_t aes_x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a, 0x2b, + 0xcf, 0xcc, 0xb3, 0x56, 0x05, 0x15, 0x5f, 0xf3, + 0x6e, 0xd8, 0xed, 0xd4, 0xa4, 0x0d, 0xcd, 0x4b, + 0x24, 0x3a, 0xcd, 0x11, 0xb2, 0xb9, 0x87, 0xbd, + 0xbf, 0xaf, 0x91, 0xa7, 0xca, 0xc2, 0x7e, 0x9c, + 0x5a, 0xea, 0x52, 0x5e, 0xe5, 0x3d, 0xe7, 0xb2, + 0xd3, 0x33, 0x2c, 0x86, 0x44, 0x40, 0x2b, 0x82, + 0x3e, 0x94, 0xa7, 0xdb, 0x26, 0x27, 0x6d, 0x2d, + 0x23, 0xaa, 0x07, 0x18, 0x0f, 0x76, 0xb4, 0xfd, + 0x29, 0xb9, 0xc0, 0x82, 0x30, 0x99, 0xc9, 0xd6, + 0x2c, 0x51, 0x98, 0x80, 0xae, 0xe7, 0xe9, 0x69, + 0x76, 0x17, 0xc1, 0x49, 0x7d, 0x47, 0xbf, 0x3e, + 0x57, 0x19, 0x50, 0x31, 0x14, 0x21, 0xb6, 0xb7, + 0x34, 0xd3, 0x8b, 0x0d, 0xb9, 0x1e, 0xb8, 0x53, + 0x31, 0xb9, 0x1e, 0xa9, 0xf6, 0x15, 0x30, 0xf5, + 0x45, 0x12, 0xa5, 0xa5, 0x2a, 0x4b, 0xad, 0x58, + 0x9e, 0xb6, 0x97, 0x81, 0xd5, 0x37, 0xf2, 0x32, + 0x97, 0xbb, 0x45, 0x9b, 0xda, 0xd2, 0x94, 0x8a, + 0x29, 0xe1, 0x55, 0x0b, 0xf4, 0x78, 0x7e, 0x0b, + 0xe9, 0x5b, 0xb1, 0x73, 0xcf, 0x5f, 0xab, 0x17, + 0xda, 0xb7, 0xa1, 0x3a, 0x05, 0x2a, 0x63, 0x45, + 0x3d, 0x97, 0xcc, 0xec, 0x1a, 0x32, 0x19, 0x54, + 0x88, 0x6b, 0x7a, 0x12, 0x99, 0xfa, 0xae, 0xec, + 0xae, 0x35, 0xc6, 0xea, 0xac, 0xa7, 0x53, 0xb0, + 0x41, 0xb5, 0xe5, 0xf0, 0x93, 0xbf, 0x83, 0x39, + 0x7f, 0xd2, 0x1d, 0xd6, 0xb3, 0x01, 0x20, 0x66, + 0xfc, 0xc0, 0x58, 0xcc, 0x32, 0xc3, 0xb0, 0x9d, + 0x75, 0x62, 0xde, 0xe2, 0x95, 0x09, 0xb5, 0x83, + 0x93, 0x92, 0xc9, 0xff, 0x05, 0xf5, 0x1f, 0x31, + 0x66, 0xaa, 0xac, 0x4a, 0xc5, 0xf2, 0x38, 0x03, + 0x8a, 0x30, 0x45, 0xe6, 0xf7, 0x2e, 0x48, 0xef, + 0x0f, 0xe8, 0xbc, 0x67, 0x5e, 0x82, 0xc3, 0x18, + 0xa2, 0x68, 0xe4, 0x39, 0x70, 0x27, 0x1b, 0xf1, + 0x19, 0xb8, 0x1b, 0xf6, 0xa9, 0x82, 0x74, 0x65, + 0x54, 0xf8, 0x4e, 0x72, 0xb9, 0xf0, 0x02, 0x80, + 0xa3, 0x20, 0xa0, 0x81, 0x42, 0x92, 0x3c, 0x23, + 0xc8, 0x83, 0x42, 0x3f, 0xf9, 0x49, 0x82, 0x7f, + 0x29, 0xbb, 0xac, 0xdc, 0x1c, 0xcd, 0xb0, 0x49, + 0x38, 0xce, 0x60, 0x98, 0xc9, 0x5b, 0xa6, 0xb3, + 0x25, 0x28, 0xf4, 0xef, 0x78, 0xee, 0xd7, 0x78, + 0xb2, 0xe1, 0x22, 0xdd, 0xfd, 0x1c, 0xbd, 0xd1, + 0x1d, 0x1c, 0x0a, 0x67, 0x83, 0xe0, 0x11, 0xfc, + 0x53, 0x6d, 0x63, 0xd0, 0x53, 0x26, 0x06, 0x37, +}; + +static const uint8_t aes_xts_256_vec8_ctxt[SECSIZE] = { + 0x72, 0xef, 0xc1, 0xeb, 0xfe, 0x1e, 0xe2, 0x59, + 0x75, 0xa6, 0xeb, 0x3a, 0xa8, 0x58, 0x9d, 0xda, + 0x2b, 0x26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0xa5, 0xf6, 0xe6, + 0x53, 0xf7, 0x51, 0x69, 0x3e, 0x6b, 0x6a, 0x2b, + 0x8e, 0xad, 0x57, 0xd5, 0x11, 0xe0, 0x0e, 0x58, + 0xc4, 0x5b, 0x7b, 0x8d, 0x00, 0x5a, 0xf7, 0x92, + 0x88, 0xf5, 0xc7, 0xc2, 0x2f, 0xd4, 0xf1, 0xbf, + 0x7a, 0x89, 0x8b, 0x03, 0xa5, 0x63, 0x4c, 0x6a, + 0x1a, 0xe3, 0xf9, 0xfa, 0xe5, 0xde, 0x4f, 0x29, + 0x6a, 0x28, 0x96, 0xb2, 0x3e, 0x7e, 0xd4, 0x3e, + 0xd1, 0x4f, 0xa5, 0xa2, 0x80, 0x3f, 0x4d, 0x28, + 0xf0, 0xd3, 0xff, 0xcf, 0x24, 0x75, 0x76, 0x77, + 0xae, 0xbd, 0xb4, 0x7b, 0xb3, 0x88, 0x37, 0x87, + 0x08, 0x94, 0x8a, 0x8d, 0x41, 0x26, 0xed, 0x18, + 0x39, 0xe0, 0xda, 0x29, 0xa5, 0x37, 0xa8, 0xc1, + 0x98, 0xb3, 0xc6, 0x6a, 0xb0, 0x07, 0x12, 0xdd, + 0x26, 0x16, 0x74, 0xbf, 0x45, 0xa7, 0x3d, 0x67, + 0xf7, 0x69, 0x14, 0xf8, 0x30, 0xca, 0x01, 0x4b, + 0x65, 0x59, 0x6f, 0x27, 0xe4, 0xcf, 0x62, 0xde, + 0x66, 0x12, 0x5a, 0x55, 0x66, 0xdf, 0x99, 0x75, + 0x15, 0x56, 0x28, 0xb4, 0x00, 0xfb, 0xfb, 0x3a, + 0x29, 0x04, 0x0e, 0xd5, 0x0f, 0xaf, 0xfd, 0xbb, + 0x18, 0xae, 0xce, 0x7c, 0x5c, 0x44, 0x69, 0x32, + 0x60, 0xaa, 0xb3, 0x86, 0xc0, 0xa3, 0x7b, 0x11, + 0xb1, 0x14, 0xf1, 0xc4, 0x15, 0xae, 0xbb, 0x65, + 0x3b, 0xe4, 0x68, 0x17, 0x94, 0x28, 0xd4, 0x3a, + 0x4d, 0x8b, 0xc3, 0xec, 0x38, 0x81, 0x3e, 0xca, + 0x30, 0xa1, 0x3c, 0xf1, 0xbb, 0x18, 0xd5, 0x24, + 0xf1, 0x99, 0x2d, 0x44, 0xd8, 0xb1, 0xa4, 0x2e, + 0xa3, 0x0b, 0x22, 0xe6, 0xc9, 0x5b, 0x19, 0x9d, + 0x8d, 0x18, 0x2f, 0x88, 0x40, 0xb0, 0x9d, 0x05, + 0x95, 0x85, 0xc3, 0x1a, 0xd6, 0x91, 0xfa, 0x06, + 0x19, 0xff, 0x03, 0x8a, 0xca, 0x2c, 0x39, 0xa9, + 0x43, 0x42, 0x11, 0x57, 0x36, 0x17, 0x17, 0xc4, + 0x9d, 0x32, 0x20, 0x28, 0xa7, 0x46, 0x48, 0x11, + 0x3b, 0xd8, 0xc9, 0xd7, 0xec, 0x77, 0xcf, 0x3c, + 0x89, 0xc1, 0xec, 0x87, 0x18, 0xce, 0xff, 0x85, + 0x16, 0xd9, 0x6b, 0x34, 0xc3, 0xc6, 0x14, 0xf1, + 0x06, 0x99, 0xc9, 0xab, 0xc4, 0xed, 0x04, 0x11, + 0x50, 0x62, 0x23, 0xbe, 0xa1, 0x6a, 0xf3, 0x5c, + 0x88, 0x3a, 0xcc, 0xdb, 0xe1, 0x10, 0x4e, 0xef, + 0x0c, 0xfd, 0xb5, 0x4e, 0x12, 0xfb, 0x23, 0x0a, +}; + +/* + * Vector 9 from IEEE 1619/D16, blkno 0xff. + */ +static const uint8_t aes_xts_256_vec9_ptxt[SECSIZE] = { + 0x72, 0xef, 0xc1, 0xeb, 0xfe, 0x1e, 0xe2, 0x59, + 0x75, 0xa6, 0xeb, 0x3a, 0xa8, 0x58, 0x9d, 0xda, + 0x2b, 0x26, 0x1f, 0x1c, 0x85, 0xbd, 0xab, 0x44, + 0x2a, 0x9e, 0x5b, 0x2d, 0xd1, 0xd7, 0xc3, 0x95, + 0x7a, 0x16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xe0, 0x0e, 0x58, + 0xc4, 0x5b, 0x7b, 0x8d, 0x00, 0x5a, 0xf7, 0x92, + 0x88, 0xf5, 0xc7, 0xc2, 0x2f, 0xd4, 0xf1, 0xbf, + 0x7a, 0x89, 0x8b, 0x03, 0xa5, 0x63, 0x4c, 0x6a, + 0x1a, 0xe3, 0xf9, 0xfa, 0xe5, 0xde, 0x4f, 0x29, + 0x6a, 0x28, 0x96, 0xb2, 0x3e, 0x7e, 0xd4, 0x3e, + 0xd1, 0x4f, 0xa5, 0xa2, 0x80, 0x3f, 0x4d, 0x28, + 0xf0, 0xd3, 0xff, 0xcf, 0x24, 0x75, 0x76, 0x77, + 0xae, 0xbd, 0xb4, 0x7b, 0xb3, 0x88, 0x37, 0x87, + 0x08, 0x94, 0x8a, 0x8d, 0x41, 0x26, 0xed, 0x18, + 0x39, 0xe0, 0xda, 0x29, 0xa5, 0x37, 0xa8, 0xc1, + 0x98, 0xb3, 0xc6, 0x6a, 0xb0, 0x07, 0x12, 0xdd, + 0x26, 0x16, 0x74, 0xbf, 0x45, 0xa7, 0x3d, 0x67, + 0xf7, 0x69, 0x14, 0xf8, 0x30, 0xca, 0x01, 0x4b, + 0x65, 0x59, 0x6f, 0x27, 0xe4, 0xcf, 0x62, 0xde, + 0x66, 0x12, 0x5a, 0x55, 0x66, 0xdf, 0x99, 0x75, + 0x15, 0x56, 0x28, 0xb4, 0x00, 0xfb, 0xfb, 0x3a, + 0x29, 0x04, 0x0e, 0xd5, 0x0f, 0xaf, 0xfd, 0xbb, + 0x18, 0xae, 0xce, 0x7c, 0x5c, 0x44, 0x69, 0x32, + 0x60, 0xaa, 0xb3, 0x86, 0xc0, 0xa3, 0x7b, 0x11, + 0xb1, 0x14, 0xf1, 0xc4, 0x15, 0xae, 0xbb, 0x65, + 0x3b, 0xe4, 0x68, 0x17, 0x94, 0x28, 0xd4, 0x3a, + 0x4d, 0x8b, 0xc3, 0xec, 0x38, 0x81, 0x3e, 0xca, + 0x30, 0xa1, 0x3c, 0xf1, 0xbb, 0x18, 0xd5, 0x24, + 0xf1, 0x99, 0x2d, 0x44, 0xd8, 0xb1, 0xa4, 0x2e, + 0xa3, 0x0b, 0x22, 0xe6, 0xc9, 0x5b, 0x19, 0x9d, + 0x8d, 0x18, 0x2f, 0x88, 0x40, 0xb0, 0x9d, 0x05, + 0x95, 0x85, 0xc3, 0x1a, 0xd6, 0x91, 0xfa, 0x06, + 0x19, 0xff, 0x03, 0x8a, 0xca, 0x2c, 0x39, 0xa9, + 0x43, 0x42, 0x11, 0x57, 0x36, 0x17, 0x17, 0xc4, + 0x9d, 0x32, 0x20, 0x28, 0xa7, 0x46, 0x48, 0x11, + 0x3b, 0xd8, 0xc9, 0xd7, 0xec, 0x77, 0xcf, 0x3c, + 0x89, 0xc1, 0xec, 0x87, 0x18, 0xce, 0xff, 0x85, + 0x16, 0xd9, 0x6b, 0x34, 0xc3, 0xc6, 0x14, 0xf1, + 0x06, 0x99, 0xc9, 0xab, 0xc4, 0xed, 0x04, 0x11, + 0x50, 0x62, 0x23, 0xbe, 0xa1, 0x6a, 0xf3, 0x5c, + 0x88, 0x3a, 0xcc, 0xdb, 0xe1, 0x10, 0x4e, 0xef, + 0x0c, 0xfd, 0xb5, 0x4e, 0x12, 0xfb, 0x23, 0x0a, +}; + +static const uint8_t aes_xts_256_vec9_ctxt[SECSIZE] = { + 0x32, 0x60, 0xae, 0x8d, 0xad, 0x1f, 0x4a, 0x32, + 0xc5, 0xca, 0xfe, 0x3a, 0xb0, 0xeb, 0x95, 0x54, + 0x9d, 0x46, 0x1a, 0x67, 0xce, 0xb9, 0xe5, 0xaa, + 0x2d, 0x3a, 0xfb, 0x62, 0xde, 0xce, 0x05, 0x53, + 0x19, 0x3b, 0xa5, 0x0c, 0x75, 0xbe, 0x25, 0x1e, + 0x08, 0xd1, 0xd0, 0x8f, 0x10, 0x88, 0x57, 0x6c, + 0x7e, 0xfd, 0xfa, 0xaf, 0x3f, 0x45, 0x95, 0x59, + 0x57,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 0xfd, 0xd3, + 0x86, 0x75, 0x71, 0x3c, 0x8d, 0xaa, 0xdd, 0x17, + 0xe1, 0xca, 0xbe, 0xe4, 0x32, 0xb0, 0x97, 0x87, + 0xb6, 0xdd, 0xf3, 0x30, 0x4e, 0x38, 0xb7, 0x31, + 0xb4, 0x5d, 0xf5, 0xdf, 0x51, 0xb7, 0x8f, 0xcf, + 0xb3, 0xd3, 0x24, 0x66, 0x02, 0x8d, 0x0b, 0xa3, + 0x65, 0x55, 0xe7, 0xe1, 0x1a, 0xb0, 0xee, 0x06, + 0x66, 0x06, 0x1d, 0x16, 0x45, 0xd9, 0x62, 0x44, + 0x4b, 0xc4, 0x7a, 0x38, 0x18, 0x89, 0x30, 0xa8, + 0x4b, 0x4d, 0x56, 0x13, 0x95, 0xc7, 0x3c, 0x08, + 0x70, 0x21, 0x92, 0x7c, 0xa6, 0x38, 0xb7, 0xaf, + 0xc8, 0xa8, 0x67, 0x9c, 0xcb, 0x84, 0xc2, 0x65, + 0x55, 0x44, 0x0e, 0xc7, 0xf1, 0x04, 0x45, 0xcd, +}; + +const struct testvec aes_xts_256_vectors[] = { + { + .blkno = 0, + .ptxt = aes_xts_256_vec4_ptxt, + .ctxt = aes_xts_256_vec4_ctxt, + }, + { + .blkno = 1, + .ptxt = aes_xts_256_vec5_ptxt, + .ctxt = aes_xts_256_vec5_ctxt, + }, + { + .blkno = 2, + .ptxt = aes_xts_256_vec6_ptxt, + .ctxt = aes_xts_256_vec6_ctxt, + }, + { + .blkno = 0xfd, + .ptxt = aes_xts_256_vec7_ptxt, + .ctxt = aes_xts_256_vec7_ctxt, + }, + { + .blkno = 0xfe, + .ptxt = aes_xts_256_vec8_ptxt, + .ctxt = aes_xts_256_vec8_ctxt, + }, + { + .blkno = 0xff, + .ptxt = aes_xts_256_vec9_ptxt, + .ctxt = aes_xts_256_vec9_ctxt, + }, +}; + +/* + * Vector 10 from IEEE 1619/D16, blkno 0xff. + */ +static const uint8_t aes_xts_512_vec10_ptxt[SECSIZE] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a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, 0x48, 0x23, 0x57, + 0xa4, 0xae, 0x12, 0xd4, 0x14, 0xa3, 0xe6, 0x3b, + 0x5d, 0x31, 0xe2, 0x76, 0xf8, 0xfe, 0x4a, 0x8d, + 0x66, 0xb3, 0x17, 0xf9, 0xac, 0x68, 0x3f, 0x44, + 0x68, 0x0a, 0x86, 0xac, 0x35, 0xad, 0xfc, 0x33, + 0x45, 0xbe, 0xfe, 0xcb, 0x4b, 0xb1, 0x88, 0xfd, + 0x57, 0x76, 0x92, 0x6c, 0x49, 0xa3, 0x09, 0x5e, + 0xb1, 0x08, 0xfd, 0x10, 0x98, 0xba, 0xec, 0x70, + 0xaa, 0xa6, 0x69, 0x99, 0xa7, 0x2a, 0x82, 0xf2, + 0x7d, 0x84, 0x8b, 0x21, 0xd4, 0xa7, 0x41, 0xb0, + 0xc5, 0xcd, 0x4d, 0x5f, 0xff, 0x9d, 0xac, 0x89, + 0xae, 0xba, 0x12, 0x29, 0x61, 0xd0, 0x3a, 0x75, + 0x71, 0x23, 0xe9, 0x87, 0x0f, 0x8a, 0xcf, 0x10, + 0x00, 0x02, 0x08, 0x87, 0x89, 0x14, 0x29, 0xca, + 0x2a, 0x3e, 0x7a, 0x7d, 0x7d, 0xf7, 0xb1, 0x03, + 0x55, 0x16, 0x5c, 0x8b, 0x9a, 0x6d, 0x0a, 0x7d, + 0xe8, 0xb0, 0x62, 0xc4, 0x50, 0x0d, 0xc4, 0xcd, + 0x12, 0x0c, 0x0f, 0x74, 0x18, 0xda, 0xe3, 0xd0, + 0xb5, 0x78, 0x1c, 0x34, 0x80, 0x3f, 0xa7, 0x54, + 0x21, 0xc7, 0x90, 0xdf, 0xe1, 0xde, 0x18, 0x34, + 0xf2, 0x80, 0xd7, 0x66, 0x7b, 0x32, 0x7f, 0x6c, + 0x8c, 0xd7, 0x55, 0x7e, 0x12, 0xac, 0x3a, 0x0f, + 0x93, 0xec, 0x05, 0xc5, 0x2e, 0x04, 0x93, 0xef, + 0x31, 0xa1, 0x2d, 0x3d, 0x92, 0x60, 0xf7, 0x9a, + 0x28, 0x9d, 0x6a, 0x37, 0x9b, 0xc7, 0x0c, 0x50, + 0x84, 0x14, 0x73, 0xd1, 0xa8, 0xcc, 0x81, 0xec, + 0x58, 0x3e, 0x96, 0x45, 0xe0, 0x7b, 0x8d, 0x96, + 0x70, 0x65, 0x5b, 0xa5, 0xbb, 0xcf, 0xec, 0xc6, + 0xdc, 0x39, 0x66, 0x38, 0x0a, 0xd8, 0xfe, 0xcb, + 0x17, 0xb6, 0xba, 0x02, 0x46, 0x9a, 0x02, 0x0a, + 0x84, 0xe1, 0x8e, 0x8f, 0x84, 0x25, 0x20, 0x70, + 0xc1, 0x3e, 0x9f, 0x1f, 0x28, 0x9b, 0xe5, 0x4f, + 0xbc, 0x48, 0x14, 0x57, 0x77, 0x8f, 0x61, 0x60, + 0x15, 0xe1, 0x32, 0x7a, 0x02, 0xb1, 0x40, 0xf1, + 0x50, 0x5e, 0xb3, 0x09, 0x32, 0x6d, 0x68, 0x37, + 0x8f, 0x83, 0x74, 0x59, 0x5c, 0x84, 0x9d, 0x84, + 0xf4, 0xc3, 0x33, 0xec, 0x44, 0x23, 0x88, 0x51, + 0x43, 0xcb, 0x47, 0xbd, 0x71, 0xc5, 0xed, 0xae, + 0x9b, 0xe6, 0x9a, 0x2f, 0xfe, 0xce, 0xb1, 0xbe, + 0xc9, 0xde, 0x24, 0x4f, 0xbe, 0x15, 0x99, 0x2b, + 0x11, 0xb7, 0x7c, 0x04, 0x0f, 0x12, 0xbd, 0x8f, + 0x6a, 0x97, 0x5a, 0x44, 0xa0, 0xf9, 0x0c, 0x29, + 0xa9, 0xab, 0xc3, 0xd4, 0xd8, 0x93, 0x92, 0x72, + 0x84, 0xc5, 0x87, 0x54, 0xcc, 0xe2, 0x94, 0x52, + 0x9f, 0x86, 0x14, 0xdc, 0xd2, 0xab, 0xa9, 0x91, + 0x92, 0x5f, 0xed, 0xc4, 0xae, 0x74, 0xff, 0xac, + 0x6e, 0x33, 0x3b, 0x93, 0xeb, 0x4a, 0xff, 0x04, + 0x79, 0xda, 0x9a, 0x41, 0x0e, 0x44, 0x50, 0xe0, + 0xdd, 0x7a, 0xe4, 0xc6, 0xe2, 0x91, 0x09, 0x00, + 0x57, 0x5d, 0xa4, 0x01, 0xfc, 0x07, 0x05, 0x9f, + 0x64, 0x5e, 0x8b, 0x7e, 0x9b, 0xfd, 0xef, 0x33, + 0x94, 0x30, 0x54, 0xff, 0x84, 0x01, 0x14, 0x93, + 0xc2, 0x7b, 0x34, 0x29, 0xea, 0xed, 0xb4, 0xed, + 0x53, 0x76, 0x44, 0x1a, 0x77, 0xed, 0x43, 0x85, + 0x1a, 0xd7, 0x7f, 0x16, 0xf5, 0x41, 0xdf, 0xd2, + 0x69, 0xd5, 0x0d, 0x6a, 0x5f, 0x14, 0xfb, 0x0a, + 0xab, 0x1c, 0xbb, 0x4c, 0x15, 0x50, 0xbe, 0x97, + 0xf7, 0xab, 0x40, 0x66, 0x19, 0x3c, 0x4c, 0xaa, + 0x77, 0x3d, 0xad, 0x38, 0x01, 0x4b, 0xd2, 0x09, + 0x2f, 0xa7, 0x55, 0xc8, 0x24, 0xbb, 0x5e, 0x54, + 0xc4, 0xf3, 0x6f, 0xfd, 0xa9, 0xfc, 0xea, 0x70, + 0xb9, 0xc6, 0xe6, 0x93, 0xe1, 0x48, 0xc1, 0x51, +}; + +/* + * Vector 11 from IEEE 1619/D16, blkno 0xffff. + */ +static const uint8_t aes_xts_512_vec11_ptxt[SECSIZE] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x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f, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97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42, 0x23, 0xce, + 0x8d, 0xdc, 0x23, 0x94, 0x82, 0x8d, 0x6a, 0x80, + 0x47, 0x0c, 0x09, 0x2f, 0x5b, 0xa4, 0x13, 0xc3, + 0x37, 0x8f, 0xa6, 0x05, 0x42, 0x55, 0xc6, 0xf9, + 0xdf, 0x44, 0x95, 0x86, 0x2b, 0xbb, 0x32, 0x87, + 0x68, 0x1f, 0x93, 0x1b, 0x68, 0x7c, 0x88, 0x8a, + 0xbf, 0x84, 0x4d, 0xfc, 0x8f, 0xc2, 0x83, 0x31, + 0xe5, 0x79, 0x92, 0x8c, 0xd1, 0x2b, 0xd2, 0x39, + 0x0a, 0xe1, 0x23, 0xcf, 0x03, 0x81, 0x8d, 0x14, + 0xde, 0xdd, 0xe5, 0xc0, 0xc2, 0x4c, 0x8a, 0xb0, + 0x18, 0xbf, 0xca, 0x75, 0xca, 0x09, 0x6f, 0x2d, + 0x53, 0x1f, 0x3d, 0x16, 0x19, 0xe7, 0x85, 0xf1, + 0xad, 0xa4, 0x37, 0xca, 0xb9, 0x2e, 0x98, 0x05, + 0x58, 0xb3, 0xdc, 0xe1, 0x47, 0x4a, 0xfb, 0x75, + 0xbf, 0xed, 0xbf, 0x8f, 0xf5, 0x4c, 0xb2, 0x61, + 0x8e, 0x02, 0x44, 0xc9, 0xac, 0x0d, 0x3c, 0x66, + 0xfb, 0x51, 0x59, 0x8c, 0xd2, 0xdb, 0x11, 0xf9, + 0xbe, 0x39, 0x79, 0x1a, 0xbe, 0x44, 0x7c, 0x63, + 0x09, 0x4f, 0x7c, 0x45, 0x3b, 0x7f, 0xf8, 0x7c, + 0xb5, 0xbb, 0x36, 0xb7, 0xc7, 0x9e, 0xfb, 0x08, + 0x72, 0xd1, 0x70, 0x58, 0xb8, 0x3b, 0x15, 0xab, + 0x08, 0x66, 0xad, 0x8a, 0x58, 0x65, 0x6c, 0x5a, + 0x7e, 0x20, 0xdb, 0xdf, 0x30, 0x8b, 0x24, 0x61, + 0xd9, 0x7c, 0x0e, 0xc0, 0x02, 0x4a, 0x27, 0x15, + 0x05, 0x52, 0x49, 0xcf, 0x3b, 0x47, 0x8d, 0xdd, + 0x47, 0x40, 0xde, 0x65, 0x4f, 0x75, 0xca, 0x68, + 0x6e, 0x0d, 0x73, 0x45, 0xc6, 0x9e, 0xd5, 0x0c, + 0xdc, 0x2a, 0x8b, 0x33, 0x2b, 0x1f, 0x88, 0x24, + 0x10, 0x8a, 0xc9, 0x37, 0xeb, 0x05, 0x05, 0x85, + 0x60, 0x8e, 0xe7, 0x34, 0x09, 0x7f, 0xc0, 0x90, + 0x54, 0xfb, 0xff, 0x89, 0xee, 0xae, 0xea, 0x79, + 0x1f, 0x4a, 0x7a, 0xb1, 0xf9, 0x86, 0x82, 0x94, + 0xa4, 0xf9, 0xe2, 0x7b, 0x42, 0xaf, 0x81, 0x00, + 0xcb, 0x9d, 0x59, 0xce, 0xf9, 0x64, 0x58, 0x03, +}; + +const struct testvec aes_xts_512_vectors[] = { + { + .blkno = 0xff, + .ptxt = aes_xts_512_vec10_ptxt, + .ctxt = aes_xts_512_vec10_ctxt, + }, + { + .blkno = 0xffff, + .ptxt = aes_xts_512_vec11_ptxt, + .ctxt = aes_xts_512_vec11_ctxt, + }, +}; + +static int +open_disk(const char *devpath, const char *imgpath, size_t size) +{ + int fd; + + fd = open(imgpath, O_CREAT | O_RDWR | O_TRUNC, 0600); + if (fd < 0) + return -1; + + if (ftruncate(fd, size) < 0) + goto fail; + + if (rump_pub_etfs_register_withsize(devpath, + imgpath, RUMP_ETFS_BLK, 0, size) < 0) { + goto fail; + } + + unlink(imgpath); + return fd; +fail: + close(fd); + unlink(imgpath); + return -1; +} + +static int +open_cgd(int devno) +{ + char devpath[32]; + + sprintf(devpath, "/dev/rcgd%d%c", devno, getrawpartition() + 'a'); + + return rump_sys_open(devpath, O_RDWR, 0); +} + +static int +configure_cgd(int fd, const char *dkpath, const char *alg, + const char *ivmethod, const char *key, size_t keylen) +{ + struct cgd_ioctl ci; + + memset(&ci, 0, sizeof(ci)); + ci.ci_disk = dkpath; + ci.ci_alg = alg; + ci.ci_ivmethod = ivmethod; + ci.ci_keylen = 8 * keylen - 8; /* Exclude the NUL terminator. */ + ci.ci_key = key; + ci.ci_blocksize = 128; + + return rump_sys_ioctl(fd, CGDIOCSET, &ci); +} + +static int +unconfigure_cgd(int fd) +{ + struct cgd_ioctl ci; + + return rump_sys_ioctl(fd, CGDIOCCLR, &ci); +} + +static int +write_testvec(int cgdfd, const struct testvec *tv) +{ + ssize_t written; + + if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0) + return -1; + + written = rump_sys_write(cgdfd, tv->ptxt, SECSIZE); + if (written < 0) + return -1; + if (written != SECSIZE) { + errno = EDOM; /* Something distinct. */ + return -1; + } + + return 0; +} + +static int +read_testvec(int cgdfd, const struct testvec *tv) +{ + char *buf; + int res = -1; + + buf = malloc(SECSIZE); + if (buf == NULL) + return -1; + + if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0) + goto fail; + + if (rump_sys_read(cgdfd, buf, SECSIZE) != SECSIZE) + goto fail; + + res = memcmp(buf, tv->ptxt, SECSIZE); +fail: + free(buf); + return res; +} + +static int +check_testvec(int dkfd, const struct testvec *tv) +{ + char *buf; + int res = -1; + + buf = malloc(SECSIZE); + if (buf == NULL) + return -1; + + if (lseek(dkfd, tv->blkno * SECSIZE, SEEK_SET) < 0) + goto fail; + + if (read(dkfd, buf, SECSIZE) != SECSIZE) + goto fail; + + res = memcmp(buf, tv->ctxt, SECSIZE); +fail: + free(buf); + return res; +} + +ATF_TC(cgd_aes_cbc_128_encblkno1); +ATF_TC_HEAD(cgd_aes_cbc_128_encblkno1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test aes-cbc with 128 bits key, ivmethod encblkno1"); +} + +ATF_TC_BODY(cgd_aes_cbc_128_encblkno1, tc) +{ + const char imgpath[] = "aes-cbc-128-encblkno1.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1", + aes_cbc_128_key, sizeof(aes_cbc_128_key))); + + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_1_vectors[0]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_1_vectors[1]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_1_vectors[2]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_1_vectors[3]), -1); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1", + aes_cbc_128_key, sizeof(aes_cbc_128_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_1_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_1_vectors[1]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_1_vectors[2]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_1_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_1_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_1_vectors[1]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_1_vectors[2]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_1_vectors[3]), 0); + + RL(close(dkfd)); +} + +ATF_TC(cgd_aes_cbc_128_encblkno8); +ATF_TC_HEAD(cgd_aes_cbc_128_encblkno8, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test aes-cbc with 128 bits key, ivmethod encblkno8"); +} + +ATF_TC_BODY(cgd_aes_cbc_128_encblkno8, tc) +{ + const char imgpath[] = "aes-cbc-128-encblkno8.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8", + aes_cbc_128_key, sizeof(aes_cbc_128_key))); + + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_8_vectors[0]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_8_vectors[1]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_8_vectors[2]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_8_vectors[3]), -1); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8", + aes_cbc_128_key, sizeof(aes_cbc_128_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_8_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_8_vectors[1]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_8_vectors[2]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_8_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_8_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_8_vectors[1]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_8_vectors[2]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_8_vectors[3]), 0); + + RL(close(dkfd)); +} + +ATF_TC(cgd_aes_cbc_192_encblkno1); +ATF_TC_HEAD(cgd_aes_cbc_192_encblkno1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test aes-cbc with 192 bits key, ivmethod encblkno1"); +} + +ATF_TC_BODY(cgd_aes_cbc_192_encblkno1, tc) +{ + const char imgpath[] = "aes-cbc-192-encblkno1.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1", + aes_cbc_192_key, sizeof(aes_cbc_192_key))); + + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_1_vectors[0]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_1_vectors[1]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_1_vectors[2]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_1_vectors[3]), -1); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1", + aes_cbc_192_key, sizeof(aes_cbc_192_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_1_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_1_vectors[1]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_1_vectors[2]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_1_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_1_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_1_vectors[1]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_1_vectors[2]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_1_vectors[3]), 0); + + RL(close(dkfd)); +} + +ATF_TC(cgd_aes_cbc_192_encblkno8); +ATF_TC_HEAD(cgd_aes_cbc_192_encblkno8, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test aes-cbc with 192 bits key, ivmethod encblkno8"); +} + +ATF_TC_BODY(cgd_aes_cbc_192_encblkno8, tc) +{ + const char imgpath[] = "aes-cbc-192-encblkno8.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8", + aes_cbc_192_key, sizeof(aes_cbc_192_key))); + + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_8_vectors[0]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_8_vectors[1]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_8_vectors[2]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_8_vectors[3]), -1); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8", + aes_cbc_192_key, sizeof(aes_cbc_192_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_8_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_8_vectors[1]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_8_vectors[2]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_8_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_8_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_8_vectors[1]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_8_vectors[2]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_8_vectors[3]), 0); + + RL(close(dkfd)); +} + +ATF_TC(cgd_aes_cbc_256_encblkno1); +ATF_TC_HEAD(cgd_aes_cbc_256_encblkno1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test aes-cbc with 256 bits key, ivmethod encblkno1"); +} + +ATF_TC_BODY(cgd_aes_cbc_256_encblkno1, tc) +{ + const char imgpath[] = "aes-cbc-256-encblkno1.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1", + aes_cbc_256_key, sizeof(aes_cbc_256_key))); + + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_1_vectors[0]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_1_vectors[1]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_1_vectors[2]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_1_vectors[3]), -1); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1", + aes_cbc_256_key, sizeof(aes_cbc_256_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_1_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_1_vectors[1]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_1_vectors[2]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_1_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_1_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_1_vectors[1]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_1_vectors[2]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_1_vectors[3]), 0); + + RL(close(dkfd)); +} + +ATF_TC(cgd_aes_cbc_256_encblkno8); +ATF_TC_HEAD(cgd_aes_cbc_256_encblkno8, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test aes-cbc with 256 bits key, ivmethod encblkno8"); +} + +ATF_TC_BODY(cgd_aes_cbc_256_encblkno8, tc) +{ + const char imgpath[] = "aes-cbc-256-encblkno8.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8", + aes_cbc_256_key, sizeof(aes_cbc_256_key))); + + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_8_vectors[0]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_8_vectors[1]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_8_vectors[2]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_8_vectors[3]), -1); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8", + aes_cbc_256_key, sizeof(aes_cbc_256_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_8_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_8_vectors[1]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_8_vectors[2]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_8_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_8_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_8_vectors[1]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_8_vectors[2]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_8_vectors[3]), 0); + + RL(close(dkfd)); +} + +ATF_TC(cgd_aes_xts_256); +ATF_TC_HEAD(cgd_aes_xts_256, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test aes-xts with 256 bits key"); +} + +ATF_TC_BODY(cgd_aes_xts_256, tc) +{ + const char imgpath[] = "aes-xts-256.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 256 * SECSIZE; /* Last blkno is 0xff. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "aes-xts", "encblkno1", + aes_xts_256_key, sizeof(aes_xts_256_key))); + + CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[0]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[1]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[2]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[3]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[4]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[5]), -1); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "aes-xts", "encblkno1", + aes_xts_256_key, sizeof(aes_xts_256_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[1]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[2]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[3]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[4]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[5]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[1]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[2]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[3]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[4]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[5]), 0); + + RL(close(dkfd)); +} + +ATF_TC(cgd_aes_xts_512); +ATF_TC_HEAD(cgd_aes_xts_512, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test aes-xts with 512 bits key"); +} + +ATF_TC_BODY(cgd_aes_xts_512, tc) +{ + const char imgpath[] = "aes-xts-512.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 65536 * SECSIZE; /* Last blkno is 0xffff. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "aes-xts", "encblkno1", + aes_xts_512_key, sizeof(aes_xts_512_key))); + + CHECK_LIBC(write_testvec(cgdfd, &aes_xts_512_vectors[0]), -1); + CHECK_LIBC(write_testvec(cgdfd, &aes_xts_512_vectors[1]), -1); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "aes-xts", "encblkno1", + aes_xts_512_key, sizeof(aes_xts_512_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_512_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_512_vectors[1]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_512_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_512_vectors[1]), 0); + + RL(close(dkfd)); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, cgd_aes_cbc_128_encblkno1); + ATF_TP_ADD_TC(tp, cgd_aes_cbc_128_encblkno8); + ATF_TP_ADD_TC(tp, cgd_aes_cbc_192_encblkno1); + ATF_TP_ADD_TC(tp, cgd_aes_cbc_192_encblkno8); + ATF_TP_ADD_TC(tp, cgd_aes_cbc_256_encblkno1); + ATF_TP_ADD_TC(tp, cgd_aes_cbc_256_encblkno8); + ATF_TP_ADD_TC(tp, cgd_aes_xts_256); + ATF_TP_ADD_TC(tp, cgd_aes_xts_512); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/dev/cgd/t_cgd_blowfish.c b/contrib/netbsd-tests/dev/cgd/t_cgd_blowfish.c new file mode 100644 index 0000000..958ebac --- /dev/null +++ b/contrib/netbsd-tests/dev/cgd/t_cgd_blowfish.c @@ -0,0 +1,2341 @@ +/* $NetBSD: t_cgd_blowfish.c,v 1.1 2016/11/10 23:44:36 alnsn Exp $ */ +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Alexander Nasonov. + * + * 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 COPYRIGHT HOLDERS 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 + * COPYRIGHT HOLDERS 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. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "../../h_macros.h" + +#define SECSIZE 512 + +struct testvec { + unsigned int blkno; + const uint8_t *ptxt; /* PlainText */ + const uint8_t *ctxt; /* CipherText */ +}; + +/* + * 128 bits Blowfish key, NUL terminated. + */ +static const char bf_cbc_128_key[17] = { + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */ + 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, /* 89ABCDEF */ + 0 +}; + +/* + * 256 bits Blowfish key, NUL terminated. + */ +static const char bf_cbc_256_key[33] = { + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */ + 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, /* 89ABCDEF */ + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */ + 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* 89abcdef */ + 0 +}; + +/* + * 448 bits Blowfish key, NUL terminated. + */ +static const char bf_cbc_448_key[57] = { + 0x3a, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* :ABCDEFG */ + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* HIJKLMNO */ + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* PQRSTUVW */ + 0x58, 0x59, 0x5a, 0x7e, 0x3a, 0x61, 0x62, 0x63, /* XYZ~:abc */ + 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */ + 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */ + 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x23, /* tuvwxyz# */ + 0 +}; + +static const uint8_t bf_cbc_ptxt[SECSIZE] = + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop" + " abcdefghijklmnop"; + +/* + * IV method encblkno1, blkno 0. + */ +static const uint8_t bf_cbc_128_encblkno1_vec0_ctxt[SECSIZE] = { + 0x78, 0x53, 0x43, 0x2a, 0x08, 0xe7, 0x84, 0x3f, + 0xb7, 0x61, 0x9c, 0x17, 0x81, 0xbe, 0x38, 0xb9, + 0x65, 0x51, 0x68, 0xa2, 0x29, 0xd7, 0x45, 0xc9, + 0xee, 0x0e, 0x9d, 0xe1, 0x69, 0xc6, 0x81, 0x81, + 0xf3, 0x93, 0xa6, 0x62, 0xc9, 0x05, 0x2c, 0x1b, + 0x0e, 0x05, 0xca, 0xbe, 0x12, 0x25, 0x37, 0xd8, + 0x98, 0x66, 0xa2, 0xd3, 0xd0, 0x8a, 0x89, 0x57, + 0x44, 0x91, 0x1e, 0xe9, 0x07, 0x03, 0x5c, 0xa6, + 0xb8, 0x30, 0xf1, 0xc7, 0x8c, 0x66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 0x5c, 0xd3, 0x07, 0xdf, 0x4e, 0x65, 0x65, 0x9d, + 0x2e, 0x26, 0x28, 0xfa, 0xcd, 0x53, 0x77, 0x6a, + 0x77, 0xad, 0x96, 0x0b, 0x1f, 0xea, 0x03, 0xc1, + 0xdd, 0xca, 0xe8, 0xfe, 0xe8, 0x36, 0x01, 0x61, + 0x72, 0xbb, 0xed, 0xfd, 0x8d, 0xa3, 0xc2, 0x15, + 0x25, 0x4f, 0xa6, 0x1a, 0x73, 0xbd, 0xcd, 0x45, + 0xdb, 0x08, 0x74, 0x7b, 0xa8, 0x23, 0xf5, 0x74, + 0x3a, 0x18, 0x6d, 0x90, 0xe0, 0xee, 0xae, 0xfe, + 0xc8, 0xac, 0x00, 0x57, 0xa0, 0xe1, 0xfe, 0x10, + 0xd4, 0xf3, 0xa8, 0x00, 0x21, 0x3e, 0x2d, 0xf9, + 0x63, 0xb8, 0xe9, 0xa4, 0x2e, 0xf4, 0x6b, 0xd7, + 0x5c, 0xfd, 0x32, 0x6c, 0x98, 0x05, 0x38, 0x0d, + 0x29, 0xb5, 0x5a, 0x5b, 0xbb, 0xad, 0xfd, 0x46, + 0x9b, 0x6a, 0x97, 0x4c, 0x24, 0xcc, 0x7d, 0x13, + 0x25, 0xe8, 0x2c, 0xb9, 0x13, 0x54, 0xb2, 0x8a, + 0x28, 0xa0, 0x8a, 0x3a, 0x4d, 0x7e, 0xf4, 0x29, + 0xff, 0xfb, 0x4f, 0xd6, 0x3d, 0xf7, 0xca, 0x89, + 0x2a, 0x58, 0x9e, 0x42, 0x00, 0x84, 0x61, 0x58, + 0x7c, 0x94, 0xf6, 0x50, 0x48, 0x2f, 0x34, 0x88, + 0xec, 0x97, 0xef, 0x8b, 0x2f, 0x84, 0xca, 0x23, + 0xe1, 0xb7, 0x63, 0x99, 0xdd, 0x4a, 0x76, 0xdd, + 0x20, 0xc1, 0xc2, 0x56, 0x45, 0xbe, 0x75, 0x9a, + 0x40, 0x72, 0xc8, 0xfb, 0x7e, 0x40, 0x6f, 0x38, + 0xfd, 0x76, 0xa4, 0x78, 0xf5, 0xde, 0x5f, 0xb7, + 0x4a, 0xa9, 0xaf, 0xad, 0xa1, 0x8b, 0x25, 0x8f, + 0xea, 0xb3, 0xeb, 0x54, 0x39, 0x5a, 0x91, 0xfe, + 0x86, 0x18, 0xea, 0x8c, 0xd6, 0x66, 0xd5, 0x85, + 0x02, 0x2b, 0x00, 0x5d, 0x7e, 0x13, 0xa0, 0x1f, + 0x73, 0x46, 0x6d, 0x5e, 0xcd, 0xe0, 0x82, 0x02, + 0x28, 0x88, 0xbf, 0x17, 0xfd, 0x9b, 0x83, 0x2c, + 0xa2, 0xf7, 0xde, 0x51, 0x98, 0x3f, 0xe2, 0x80, + 0x66, 0x14, 0x17, 0xce, 0x8e, 0x30, 0x2d, 0xe2, + 0x24, 0x68, 0x4b, 0xe5, 0xd1, 0x09, 0xfb, 0x6e, +}; + +/* + * IV method encblkno1, blkno 1. + */ +static const uint8_t bf_cbc_128_encblkno1_vec1_ctxt[SECSIZE] = { + 0x87, 0xae, 0x01, 0x52, 0xe8, 0xe9, 0xd9, 0xba, + 0xa9, 0x18, 0x31, 0x2c, 0x1b, 0xab, 0x57, 0xad, + 0x45, 0x0e, 0x25, 0x5e, 0x0e, 0x04, 0xfa, 0xdd, + 0xf1, 0x59, 0xe6, 0xea, 0x78, 0x4b, 0x83, 0x07, + 0x8b, 0x46, 0x91, 0x09, 0x58, 0x5a, 0x11, 0x2e, + 0x54, 0x43, 0xa4, 0xc1, 0x04, 0x35, 0xd3, 0x3e, + 0xc9, 0xc8, 0xf5, 0xff, 0x69, 0x1e, 0x57, 0x85, + 0x6d, 0x91, 0x03, 0xeb, 0x8c, 0xa7, 0xe8, 0xcc, + 0x3f, 0xac, 0xf9, 0x14, 0x1e, 0x88, 0x50, 0xa5, + 0x38, 0x66, 0xa9, 0xf4, 0xf5, 0xc6, 0x30, 0x95, + 0xd6, 0x84, 0x0b, 0x81, 0xf9, 0x51, 0x05, 0x80, + 0x9a, 0x89, 0xbf, 0xd4, 0x7d, 0x6a, 0x26, 0x59, + 0x29, 0x44, 0xe7, 0x1d, 0x0e, 0xad, 0x8c, 0xa0, + 0x93, 0xe9, 0x4b, 0x4b, 0x51, 0x46, 0xa5, 0x07, + 0xe8, 0xcb, 0x59, 0xf4, 0x63, 0xb5, 0x36, 0xdb, + 0xbc, 0x54, 0x2d, 0xec, 0xf0, 0x90, 0x3a, 0xa5, + 0xed, 0xc8, 0x28, 0x0e, 0xd3, 0x79, 0xb8, 0x57, + 0xc6, 0x7f, 0x02, 0x22, 0x5e, 0x80, 0xe8, 0x7f, + 0xdf, 0xa0, 0x0f, 0xbc, 0x98, 0x79, 0x6f, 0xd2, + 0xb0, 0xb2, 0x4f, 0x9b, 0x1a, 0x21, 0x8f, 0x63, + 0xce, 0x54, 0x41, 0x64, 0xbf, 0xb9, 0xa7, 0x93, + 0xd6, 0x5b, 0x89, 0x86, 0xda, 0x90, 0x23, 0x2e, + 0x25, 0x35, 0x1a, 0x9a, 0xf5, 0x1e, 0x8f, 0xb4, + 0xe6, 0x66, 0x8e, 0x0e, 0x2d, 0x91, 0x06, 0x4b, + 0x3d, 0x4a, 0x97, 0xab, 0x9b, 0x92, 0x09, 0xaa, + 0x07, 0xbf, 0xc1, 0x7d, 0xe2, 0xbc, 0xd2, 0xf1, + 0x38, 0x8d, 0x02, 0x45, 0xc8, 0x13, 0x12, 0xda, + 0xaa, 0x53, 0xa2, 0x2c, 0x96, 0x69, 0x64, 0xce, + 0x86, 0xe4, 0x84, 0x56, 0xd0, 0xe5, 0x81, 0x99, + 0x27, 0xad, 0x86, 0x47, 0x5f, 0xaf, 0xa2, 0xa2, + 0x90, 0x7f, 0xe7, 0x86, 0xec, 0x7f, 0xf4, 0xa3, + 0xcd, 0x4f, 0x60, 0xcc, 0x1e, 0x35, 0x44, 0xe8, + 0xe9, 0x06, 0xaf, 0x5e, 0x53, 0x3d, 0x30, 0x91, + 0xfe, 0x44, 0x59, 0x66, 0x82, 0xc2, 0xea, 0x9f, + 0xc8, 0x3b, 0xe2, 0xe5, 0x58, 0xf7, 0x34, 0xd5, + 0x9e, 0xfc, 0x20, 0x84, 0x34, 0xaa, 0x4f, 0xe1, + 0xd4, 0x95, 0x76, 0x11, 0x59, 0x90, 0x90, 0xfd, + 0x4d, 0xf9, 0xb8, 0x41, 0xe1, 0xdb, 0x36, 0x05, + 0xe3, 0x0f, 0xa4, 0x4f, 0x0c, 0x61, 0x70, 0xa5, + 0x1b, 0xbf, 0xab, 0x65, 0x67, 0x75, 0x5c, 0x7d, + 0x46, 0x3b, 0x29, 0xd0, 0x3d, 0x06, 0x40, 0x25, + 0x47, 0x3e, 0x8d, 0x62, 0xf8, 0xd8, 0x08, 0xc1, + 0x03, 0x04, 0x4b, 0x5a, 0x40, 0x65, 0x84, 0x52, + 0x34, 0xa2, 0x4a, 0xcc, 0x3a, 0x9c, 0x1e, 0xbf, + 0x2d, 0xed, 0x08, 0x8b, 0xc3, 0x8f, 0x48, 0xba, + 0x06, 0x03, 0xea, 0x5b, 0xba, 0x6a, 0xac, 0x23, + 0x5a, 0x5e, 0x31, 0x08, 0x29, 0x69, 0x64, 0x44, + 0x1c, 0x31, 0xae, 0xb1, 0x86, 0x7b, 0x26, 0x89, + 0xa6, 0xbe, 0xef, 0x69, 0x81, 0xf7, 0x77, 0xd5, + 0x8e, 0x78, 0xa5, 0x11, 0x51, 0xca, 0xec, 0xd0, + 0x86, 0xa5, 0x33, 0xf3, 0x65, 0x5d, 0x04, 0xc5, + 0xd2, 0x17, 0x2a, 0xfe, 0x4a, 0x58, 0x0f, 0x98, + 0x61, 0xad, 0xc3, 0xb8, 0x5b, 0x45, 0xcc, 0x28, + 0x3d, 0x4d, 0x00, 0xf5, 0x4a, 0xe2, 0xbc, 0x6c, + 0x1b, 0x80, 0x7a, 0x2b, 0x40, 0xb8, 0x34, 0x0e, + 0x44, 0x53, 0x16, 0xda, 0x7c, 0x46, 0x8b, 0x42, + 0x5e, 0xa8, 0xe1, 0xb8, 0xf8, 0xcf, 0xff, 0x48, + 0xcf, 0x2c, 0x4c, 0x98, 0xdb, 0xe5, 0x55, 0xfe, + 0x45, 0xfa, 0xf8, 0xde, 0x72, 0xf9, 0x84, 0x3c, + 0xc0, 0x0c, 0x1f, 0x86, 0x97, 0x86, 0xb8, 0xfe, + 0x7d, 0xff, 0xa3, 0xaf, 0x68, 0x00, 0x66, 0x90, + 0xac, 0xb5, 0xd8, 0xde, 0x35, 0x01, 0xf7, 0xab, + 0xab, 0xe3, 0xe9, 0x85, 0x4c, 0x6f, 0xe6, 0xbc, + 0xce, 0x67, 0x4a, 0xbd, 0xad, 0x7b, 0xec, 0xa1, +}; + +/* + * IV method encblkno1, blkno 2. + */ +static const uint8_t bf_cbc_128_encblkno1_vec2_ctxt[SECSIZE] = { + 0x17, 0xdd, 0x0f, 0x4b, 0x28, 0x33, 0x03, 0x89, + 0x21, 0x7b, 0x67, 0x15, 0x15, 0x65, 0x08, 0x4f, + 0x65, 0x18, 0xa6, 0x4b, 0x62, 0xdb, 0x1e, 0xc2, + 0xaa, 0x82, 0xb6, 0x1d, 0xf7, 0x12, 0x9e, 0x73, + 0xfe, 0xac, 0x2f, 0x1e, 0x2b, 0xea, 0x3a, 0x4f, + 0xc3, 0x0a, 0x59, 0x80, 0x0d, 0x3d, 0xbc, 0x62, + 0x8d, 0x70, 0xef, 0x1b, 0xfb, 0xdc, 0x4e, 0xc4, + 0x97, 0xf4, 0x77, 0xb7, 0x25, 0x94, 0x13, 0x48, + 0xf2, 0x3d, 0x4c, 0xa7, 0xb8, 0x8c, 0xf5, 0x26, + 0xa4, 0x35, 0xeb, 0xa0, 0xe7, 0x68, 0xb0, 0x69, + 0xf4, 0xf6, 0x13, 0x3a, 0x57, 0xa3, 0xd2, 0x26, + 0xe6, 0x70, 0xd8, 0xd4, 0x05, 0xb5, 0x01, 0xda, + 0xc7, 0x4a, 0x79, 0x1a, 0x6d, 0xb6, 0xf6, 0xb5, + 0x7d, 0x9a, 0x5c, 0xf1, 0x6a, 0xf8, 0xd1, 0x0a, + 0xbc, 0xe7, 0xea, 0xb4, 0x99, 0x72, 0x19, 0x97, + 0x41, 0x4f, 0x14, 0x5f, 0xa3, 0xb3, 0x9b, 0x36, + 0x00, 0x08, 0x88, 0x8c, 0xce, 0x7f, 0x3a, 0x9b, + 0xb0, 0x24, 0x17, 0x95, 0xc4, 0x59, 0x30, 0x5d, + 0xc6, 0x92, 0x19, 0x12, 0x99, 0xb0, 0x08, 0xa6, + 0x04, 0xdb, 0xc6, 0xd5, 0x61, 0xe4, 0xe1, 0x68, + 0xa8, 0xd7, 0x07, 0xfe, 0x2f, 0x47, 0xea, 0x14, + 0xe5, 0xf7, 0x61, 0x9b, 0xbb, 0x98, 0xcb, 0x3b, + 0x8c, 0x41, 0xd1, 0x55, 0x59, 0xb2, 0x41, 0x61, + 0x8e, 0x60, 0x17, 0xcd, 0xe8, 0xf7, 0x1d, 0xbd, + 0x28, 0x5d, 0x1e, 0x15, 0x28, 0x80, 0x8c, 0x29, + 0x34, 0x96, 0x31, 0xda, 0xe1, 0x19, 0x88, 0xd5, + 0xe0, 0xc8, 0xb4, 0xaa, 0x04, 0x21, 0xf5, 0xef, + 0xfa, 0x0e, 0xc9, 0xa5, 0x88, 0x77, 0x49, 0xf4, + 0x02, 0x22, 0x0b, 0x8b, 0x5e, 0xe1, 0xab, 0xd4, + 0xb1, 0xb6, 0x48, 0x54, 0x96, 0x08, 0xaf, 0xa1, + 0x0b, 0xc0, 0xfe, 0x2a, 0x12, 0x36, 0x56, 0x85, + 0x6a, 0xf7, 0x3d, 0x82, 0xe6, 0xda, 0x5d, 0xfe, + 0x4f, 0x4f, 0xc9, 0x43, 0xdc, 0x0f, 0x53, 0x05, + 0x09, 0xd4, 0x9c, 0x2e, 0x6e, 0xf3, 0x52, 0x6a, + 0x10, 0xc6, 0x48, 0xb1, 0x54, 0x70, 0xab, 0x7c, + 0x31, 0xf6, 0x47, 0xef, 0x64, 0x5f, 0xff, 0x45, + 0x8c, 0x3f, 0x87, 0x3a, 0x2d, 0xa6, 0xaf, 0xb2, + 0x44, 0xdf, 0x80, 0x2e, 0x89, 0x4c, 0x94, 0x67, + 0xfc, 0x20, 0x98, 0xb4, 0xcf, 0x58, 0x1e, 0x33, + 0x55, 0x6a, 0x7c, 0x67, 0x5c, 0x28, 0x2f, 0x19, + 0x02, 0x14, 0x06, 0x93, 0x8c, 0x84, 0xae, 0x62, + 0x14, 0xf9, 0x87, 0xae, 0x85, 0xa3, 0x60, 0x26, + 0xfc, 0x8d, 0x04, 0x92, 0x27, 0xfe, 0x35, 0x7b, + 0x45, 0x9d, 0x4a, 0x86, 0x75, 0xa6, 0xb3, 0xa1, + 0x59, 0xe4, 0x4b, 0x1c, 0xd2, 0x71, 0x36, 0xfe, + 0x73, 0xed, 0x54, 0x0d, 0x9d, 0xde, 0x63, 0xb2, + 0xc0, 0x7c, 0xf2, 0xb3, 0x36, 0x62, 0x06, 0x1f, + 0xcd, 0x41, 0x92, 0x73, 0xbc, 0x11, 0x68, 0xc9, + 0x69, 0x20, 0xf9, 0xbb, 0x9a, 0xe9, 0x6c, 0x05, + 0xcf, 0x01, 0x57, 0xc4, 0x1d, 0x95, 0x5e, 0xe3, + 0xb7, 0x15, 0xde, 0xa7, 0xb5, 0x1a, 0x4e, 0x78, + 0x44, 0x5b, 0x9a, 0xee, 0x29, 0xe2, 0x22, 0x8b, + 0xe9, 0xe3, 0xe6, 0x70, 0x3e, 0xcb, 0x9f, 0x7f, + 0xc3, 0xd0, 0x2c, 0xdc, 0x55, 0xb4, 0x0d, 0x67, + 0xf5, 0xd8, 0xff, 0xbb, 0xb1, 0x02, 0xbf, 0xf6, + 0x33, 0x4e, 0x7a, 0x3a, 0x50, 0xb1, 0x01, 0x77, + 0x51, 0xef, 0xb5, 0x75, 0xb3, 0x66, 0xe8, 0xe6, + 0xd6, 0x53, 0x7d, 0x33, 0x51, 0x62, 0x5d, 0xf2, + 0x77, 0x02, 0x34, 0x42, 0xda, 0xee, 0xd9, 0xee, + 0x0b, 0x4d, 0x71, 0x5c, 0xc0, 0xec, 0xdd, 0xc0, + 0x34, 0x6f, 0xf4, 0x65, 0x32, 0xde, 0xc5, 0xb2, + 0x97, 0x60, 0x89, 0x4e, 0x3b, 0x0c, 0xf2, 0xa7, + 0x74, 0x61, 0xd7, 0xe4, 0xa6, 0x80, 0x78, 0x76, + 0xe5, 0x7d, 0xab, 0x96, 0x04, 0x00, 0x76, 0x22, +}; + +/* + * IV method encblkno1, blkno 3. + */ +static const uint8_t bf_cbc_128_encblkno1_vec3_ctxt[SECSIZE] = { + 0xdd, 0x8e, 0xce, 0x5b, 0xb8, 0x2a, 0xc8, 0x0e, + 0xd2, 0xbe, 0xcf, 0xa7, 0x2a, 0x5b, 0x0c, 0x1a, + 0xb2, 0x68, 0x5b, 0xe7, 0x53, 0xaf, 0xce, 0x56, + 0xfd, 0xbd, 0x73, 0x3c, 0x44, 0x02, 0x96, 0x57, + 0xaa, 0x47, 0x8d, 0xf1, 0x28, 0x59, 0xb6, 0xce, + 0xba, 0x1e, 0xc9, 0x78, 0x76, 0xdd, 0x43, 0x3a, + 0xbc, 0x43, 0x4c, 0x17, 0xd2, 0xba, 0xb1, 0xda, + 0xa8, 0xbf, 0x32, 0x25, 0xaa, 0xc0, 0xf7, 0xb6, + 0x72, 0x65, 0xe2, 0x67, 0xdb, 0xf0, 0xa8, 0x60, + 0xda, 0x9b, 0x70, 0xad, 0x8f, 0x1d, 0x34, 0x24, + 0x1a, 0xfd, 0x77, 0x2e, 0x1c, 0xb6, 0xc0, 0x6b, + 0xa0, 0x4b, 0x4a, 0xa0, 0xd5, 0x8b, 0xbb, 0xd4, + 0xcc, 0x7b, 0x4e, 0x4c, 0x71, 0x9a, 0x50, 0x12, + 0x36, 0xd4, 0xfd, 0x1f, 0xf1, 0xfc, 0x19, 0x31, + 0xec, 0x54, 0x24, 0xb4, 0x9f, 0xa9, 0xea, 0xd2, + 0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d, 0xe2, 0x34, 0xf7, + 0x8f, 0x30, 0xd5, 0xd5, 0x1f, 0x17, 0x0d, 0x00, + 0x6c, 0x50, 0xde, 0x56, 0x15, 0x33, 0x1b, 0x83, + 0x68, 0x7b, 0x24, 0xe3, 0xa0, 0xda, 0xd5, 0x7a, + 0x3e, 0x93, 0x6d, 0xe0, 0x02, 0x79, 0x62, 0x5d, + 0x71, 0xe3, 0x7b, 0xa9, 0x0b, 0x7a, 0xcd, 0xb3, + 0xb2, 0x6f, 0x96, 0x19, 0x8f, 0xf8, 0x8b, 0x26, + 0x7a, 0x40, 0xc8, 0xae, 0xfe, 0x0d, 0x6f, 0x67, + 0xce, 0x5e, 0xa0, 0x04, 0x7e, 0x93, 0x1d, 0x17, + 0x1c, 0x32, 0x82, 0xf4, 0x54, 0xb9, 0x80, 0xdd, + 0x82, 0xae, 0xf5, 0xc5, 0x1e, 0x15, 0xab, 0xc2, + 0x5c, 0x60, 0xd2, 0x08, 0xc2, 0xa1, 0x1f, 0x89, + 0x0b, 0x59, 0x36, 0x07, 0xdc, 0x57, 0xd3, 0xa0, + 0x32, 0x42, 0xac, 0xa6, 0x90, 0x0b, 0xc0, 0xe4, + 0x91, 0x45, 0x85, 0x27, 0xb9, 0x48, 0x2a, 0x88, + 0x0a, 0xbf, 0xf6, 0x2d, 0xef, 0x4d, 0x1b, 0x64, + 0x49, 0x23, 0x47, 0x30, 0x29, 0x25, 0xb2, 0xc9, + 0xaf, 0xcd, 0xae, 0x56, 0x43, 0x28, 0xcf, 0x81, + 0x95, 0xa7, 0x3e, 0x51, 0x5b, 0x3b, 0xf7, 0x87, + 0x13, 0xc6, 0xee, 0x50, 0x2f, 0x78, 0xdd, 0xcf, + 0x63, 0xef, 0x15, 0xb9, 0x4f, 0x21, 0x27, 0x5e, + 0x94, 0x78, 0xad, 0xcd, 0x9b, 0x3d, 0xf2, 0xdb, + 0xed, 0xf2, 0xa2, 0x39, 0xca, 0xa3, 0xa8, 0x2e, + 0x68, 0xd5, 0xc3, 0xcf, 0x71, 0xec, 0x92, 0xdc, + 0xce, 0xe7, 0x7d, 0x2b, 0xf7, 0xbc, 0xe9, 0x2b, + 0x2e, 0xae, 0xaf, 0x0b, 0x92, 0x72, 0xac, 0x6e, + 0x49, 0xe1, 0xb3, 0x1f, 0xe5, 0x43, 0x2f, 0xa7, +}; + +const struct testvec bf_cbc_128_1_vectors[] = { + { + .blkno = 0, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_128_encblkno1_vec0_ctxt, + }, + { + .blkno = 1, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_128_encblkno1_vec1_ctxt, + }, + { + .blkno = 2, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_128_encblkno1_vec2_ctxt, + }, + { + .blkno = 3, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_128_encblkno1_vec3_ctxt, + }, +}; + +/* + * IV method encblkno8, blkno 0. + */ +static const uint8_t bf_cbc_128_encblkno8_vec0_ctxt[SECSIZE] = { + 0xb8, 0x65, 0x67, 0x8e, 0xe4, 0xd8, 0xb4, 0x93, + 0xa5, 0xbb, 0x13, 0x92, 0x27, 0x4b, 0xdd, 0xeb, + 0x0d, 0xad, 0x80, 0x6a, 0x57, 0x37, 0xc0, 0x23, + 0x23, 0xbf, 0xed, 0x86, 0x0c, 0x18, 0x48, 0x19, + 0xcd, 0x84, 0x66, 0xa7, 0xd6, 0xa0, 0x44, 0xd3, + 0x05, 0x4e, 0xf4, 0xfe, 0x6a, 0x57, 0x69, 0x01, + 0xaa, 0x91, 0x9c, 0x6e, 0x4f, 0x79, 0xc9, 0x8f, + 0x4c, 0xdf, 0x5b, 0x9c, 0xc4, 0xf7, 0x63, 0x16, + 0x20, 0x09, 0x07, 0x3f, 0x5e, 0x31, 0xcc, 0x81, + 0x71, 0xe3, 0x7b, 0xb5, 0xea, 0x2c, 0xb5, 0x14, + 0x1e, 0xf9, 0x0d, 0xe0, 0x45, 0xbc, 0x9f,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 0x58, 0x6c, 0xcb, 0xe4, 0x29, 0x04, 0x69, + 0x4f, 0x45, 0xc2, 0x59, 0x98, 0x20, 0x91, 0x6e, + 0x95, 0x82, 0xb3, 0x47, 0x2c, 0xef, 0xdb, 0x96, + 0x38, 0xba, 0x01, 0x89, 0x84, 0x96, 0x71, 0xf9, + 0x2b, 0x23, 0xe0, 0x89, 0xb8, 0xb9, 0x80, 0xbf, + 0x0c, 0xdc, 0xf0, 0x5c, 0xd6, 0x4f, 0x18, 0x19, + 0xfe, 0x23, 0x5a, 0x1e, 0x20, 0x9a, 0x05, 0xf2, + 0x62, 0xd4, 0x04, 0x92, 0x24, 0xfc, 0xc0, 0x48, + 0xf0, 0x00, 0xb4, 0xbe, 0x2e, 0xea, 0x25, 0x17, + 0x5d, 0xab, 0x73, 0x26, 0x79, 0x77, 0xc5, 0x96, + 0xd3, 0xbf, 0x38, 0xda, 0x0f, 0xe1, 0x26, 0x9a, + 0x38, 0xfc, 0x43, 0x82, 0xd1, 0x4d, 0xf2, 0xae, + 0x98, 0x1e, 0xb0, 0x0d, 0xec, 0x7b, 0x56, 0x66, + 0xcb, 0x30, 0x57, 0x4f, 0xe7, 0x03, 0xe3, 0xa6, + 0x4a, 0x4a, 0xf9, 0xa3, 0xbf, 0x44, 0xac, 0x1a, + 0xe7, 0x4b, 0xc1, 0x5b, 0x03, 0x25, 0x4e, 0xc6, + 0x1f, 0x96, 0x4d, 0xf7, 0xbe, 0xa7, 0x5d, 0x60, + 0x20, 0x62, 0x10, 0xd7, 0xab, 0x64, 0xce, 0x22, + 0x8b, 0x52, 0x76, 0xa1, 0xa1, 0x8b, 0x1e, 0xb2, + 0x18, 0x29, 0x8f, 0xc5, 0x24, 0x39, 0xd4, 0xf8, + 0x75, 0x1e, 0x30, 0x57, 0x12, 0x01, 0x04, 0x78, + 0x68, 0x97, 0xa8, 0x65, 0x8c, 0xac, 0xb4, 0x3b, + 0x37, 0x45, 0x41, 0xbc, 0x7d, 0x4b, 0x09, 0xd7, + 0x46, 0x40, 0x99, 0x59, 0xa1, 0xb5, 0x9e, 0x84, + 0x24, 0x6d, 0xfb, 0x74, 0x22, 0xac, 0x4e, 0x5f, + 0x11, 0xd3, 0xa7, 0x9f, 0xa5, 0xca, 0x38, 0x54, + 0xe2, 0x65, 0x52, 0x02, 0x69, 0xe9, 0xa8, 0xf1, + 0xd7, 0x9d, 0x9a, 0x17, 0x54, 0xa0, 0xda, 0xbb, + 0x37, 0xb4, 0x0c, 0xb6, 0x00, 0xad, 0x6f, 0x88, + 0x84, 0xa7, 0x69, 0xd7, 0x0b, 0xbe, 0xb4, 0xbe, + 0x96, 0xbc, 0xcd, 0x08, 0xf1, 0x28, 0xe0, 0x6f, +}; + +/* + * IV method encblkno8, blkno 1. + */ +static const uint8_t bf_cbc_128_encblkno8_vec1_ctxt[SECSIZE] = { + 0x7d, 0x95, 0x5a, 0x66, 0x23, 0x98, 0xa8, 0xbe, + 0x53, 0x63, 0x0d, 0x46, 0x4e, 0x38, 0x1b, 0x1d, + 0x36, 0xdd, 0x2a, 0x57, 0x3c, 0x17, 0x01, 0xba, + 0x4e, 0xf8, 0xaa, 0x22, 0x74, 0x05, 0xa2, 0x40, + 0xd0, 0x30, 0x61, 0x6c, 0x65, 0x5e, 0xfb, 0x21, + 0x63, 0xef, 0x62, 0x01, 0x74, 0x15, 0xf6, 0x87, + 0x92, 0xc1, 0x4e, 0x46, 0xdd, 0x76, 0xdb, 0x8b, + 0x20, 0x44, 0xc4, 0xfa, 0x7c, 0xd2, 0x07, 0x32, + 0x11, 0xeb, 0x5b, 0x38, 0x44, 0x32, 0xa1, 0xe7, + 0xcb, 0xa6, 0x1a, 0x12, 0xb9, 0x53, 0x13, 0x6f, + 0xc2, 0x0e, 0x6a, 0x77, 0x8b, 0x96, 0x14, 0x0a, + 0x23, 0x48, 0x65, 0xa5, 0xcd, 0x39, 0x38, 0x03, + 0xc8, 0x3a, 0x98, 0x69, 0x3d, 0x14, 0xae, 0xad, + 0x54, 0x57, 0xf6, 0x5a, 0xdd, 0x46, 0x4c, 0x3a, + 0x68, 0xa8, 0xb7, 0x57, 0xdd, 0x1e, 0x66, 0x0e, + 0xc2, 0x4c, 0x17, 0xba, 0xa4, 0x7e, 0x83, 0x45, + 0xc6, 0xf2, 0x34, 0x3b, 0x4e, 0xab, 0x67, 0x0c, + 0x73, 0xbf, 0x87, 0x7e, 0x93, 0x2b, 0x14, 0x33, + 0xd6, 0x24, 0x8d, 0xc7, 0x90, 0x11, 0xd2, 0x38, + 0xe6, 0xe0, 0x39, 0x1f, 0x00, 0x74, 0x40, 0xab, + 0xdc, 0xdd, 0x46, 0xe8, 0x85, 0x14, 0xb1, 0x78, + 0x34, 0x24, 0x04, 0x97, 0xde, 0xf9, 0x04, 0x69, + 0x0b, 0x15, 0x72, 0x37, 0xf4, 0x0d, 0xf4, 0x76, + 0x6f, 0xd8, 0x05, 0x75, 0x8f, 0x7e, 0x6b, 0xca, + 0x55, 0x20, 0x4a, 0x29, 0x16, 0xc1, 0x6e, 0x91, + 0x22, 0x01, 0x0d, 0x39, 0x5d, 0xb9, 0x09, 0xa4, + 0xe8, 0xc7, 0xff, 0x60, 0x39, 0xc6, 0xe4, 0x2a, + 0x1c, 0xf2, 0x3c, 0xf7, 0xf9, 0xd7, 0xde, 0x0b, + 0x0e, 0x30, 0xf1, 0x20, 0x7c, 0x93, 0x2f, 0x74, + 0x72, 0x40, 0x47, 0x2d, 0xeb, 0x8a, 0x5f, 0x69, + 0x60, 0xdf, 0xe9, 0x4d, 0x06, 0x24, 0x9c, 0x79, + 0xe7, 0x61, 0xd3, 0xa7, 0x57, 0x44, 0x49, 0x97, + 0x3a, 0xa3, 0x11, 0xc4, 0x70, 0xf4, 0x3d, 0xb5, + 0x4b, 0xb7, 0xae, 0x77, 0x36, 0xcf, 0x65, 0x3e, + 0xb6, 0x51, 0x83, 0xcb, 0x43, 0x5f, 0xd0, 0xfb, + 0x69, 0xc4, 0x1b, 0x77, 0x71, 0xcc, 0x72, 0xf4, + 0x5f, 0xc2, 0xda, 0xea, 0xa4, 0x33, 0xec, 0x8e, + 0x92, 0x22, 0x6a, 0x55, 0x34, 0x6a, 0x10, 0xb8, + 0x62, 0x66, 0xc1, 0x6f, 0x65, 0xdd, 0x9a, 0x40, + 0xa0, 0xbf, 0x88, 0xbb, 0x79, 0x1c, 0xa4, 0xaa, + 0xdf, 0xe8, 0xe7, 0x40, 0x88, 0xc6, 0x0f, 0xa2, + 0x2c, 0xee, 0xe7, 0x41, 0x32, 0x46, 0xa2, 0x46, + 0x85, 0xbf, 0x4c, 0xca, 0x4d, 0xd3, 0x9b, 0x49, + 0x43, 0x98, 0xae, 0xfc, 0x93, 0xa7, 0x94, 0x98, + 0x86, 0xa1, 0x0a, 0x85, 0x77, 0x67, 0xa6, 0x16, + 0x94, 0x76, 0xe5, 0x2f, 0x88, 0x5f, 0x24, 0x16, + 0xe5, 0x84, 0x4c, 0xd2, 0x58, 0x59, 0x82, 0x59, + 0x2c, 0xe2, 0x8d, 0xba, 0x08, 0x01, 0x67, 0x1f, + 0x2a, 0x9e, 0x4d, 0x53, 0x57, 0x2d, 0x6e, 0x35, + 0x38, 0xd5, 0x50, 0xa7, 0x0c, 0xe6, 0x77, 0x71, + 0xbe, 0x45, 0x2e, 0xf4, 0x7a, 0x3a, 0x51, 0x03, + 0x04, 0x2b, 0xd7, 0x42, 0x6c, 0x5b, 0x82, 0xba, + 0xb4, 0x09, 0xee, 0x9d, 0xea, 0x8f, 0xf0, 0xb3, + 0xb2, 0x9d, 0x0e, 0x09, 0x72, 0x8c, 0xd9, 0x1e, + 0x6d, 0x78, 0x57, 0x10, 0x1f, 0xeb, 0x4e, 0x53, + 0x57, 0x65, 0xe5, 0x43, 0xe8, 0xb4, 0xb6, 0xb8, + 0x25, 0x8a, 0xe2, 0xb3, 0x99, 0x95, 0x2c, 0xd0, + 0xc7, 0x89, 0xad, 0xdb, 0x72, 0xf0, 0x83, 0xe3, + 0x2f, 0x30, 0x33, 0xf4, 0x03, 0x14, 0x86, 0xa0, + 0xe0, 0x57, 0x15, 0x53, 0x26, 0xd0, 0x6d, 0x12, + 0x51, 0x96, 0x9b, 0x00, 0x8e, 0x41, 0xea, 0x05, + 0x75, 0x5d, 0xb3, 0x8d, 0x44, 0x7f, 0x41, 0x7f, + 0xd1, 0xed, 0x7c, 0xf7, 0xac, 0x6b, 0x21, 0xc7, + 0x0c, 0x49, 0xa1, 0x2e, 0x57, 0xa1, 0x21, 0xe2, +}; + +/* + * IV method encblkno8, blkno 2. + */ +static const uint8_t bf_cbc_128_encblkno8_vec2_ctxt[SECSIZE] = { + 0x28, 0x0c, 0x49, 0x08, 0x84, 0xcb, 0xba, 0x4a, + 0xa5, 0xb6, 0x12, 0x4c, 0x14, 0x11, 0x1f, 0x88, + 0x57, 0x78, 0x1e, 0x51, 0x7c, 0x9d, 0xba, 0x31, + 0x80, 0x14, 0xeb, 0x4a, 0x98, 0x8a, 0xb5, 0x4d, + 0xc5, 0xbd, 0xd2, 0x48, 0x1e, 0x19, 0x43, 0x54, + 0x48, 0x1d, 0x24, 0x76, 0x7d, 0xd8, 0xcc, 0xe9, + 0xd9, 0x7b, 0xa9, 0xdf, 0xe3, 0x65, 0x85, 0x10, + 0xb8, 0x11, 0xce, 0xa3, 0x07, 0x4d, 0x87, 0x3f, + 0x95, 0xfb, 0xa5, 0x06, 0xa4, 0x37, 0xb0, 0x89, + 0x03, 0xa9, 0xef, 0x62, 0x98, 0xd3, 0x85, 0xe8, + 0xb3, 0x21, 0xab, 0xe9, 0xdc, 0x03, 0x2a, 0x20, + 0xf7, 0xb1, 0xa4, 0x7a, 0xd5, 0xdc, 0x61, 0x2e, + 0x15, 0x81, 0x3e, 0xcf, 0x8d, 0x8d, 0x54, 0x19, + 0x70, 0xde, 0xa9, 0x57, 0x93, 0x87, 0xc7, 0x16, + 0x06, 0x25, 0xf3, 0x93, 0x8f, 0x73, 0x92, 0x29, + 0x1e, 0xcd, 0x5a, 0x9d, 0x8f, 0x8d, 0x44, 0x15, + 0x8d, 0x92, 0x44, 0x95, 0x7a, 0x5e, 0x1b, 0xfd, + 0x31, 0xa5, 0x8c, 0x22, 0x89, 0xbb, 0x91, 0x15, + 0xad, 0x0a, 0x73, 0x94, 0x65, 0xae, 0xca, 0xfc, + 0x7e, 0xae, 0x85, 0x45, 0xe7, 0xd7, 0x8f, 0x89, + 0x8e, 0x44, 0x62, 0x7a, 0xe0, 0xee, 0x78, 0xbd, + 0x88, 0x62, 0x8e, 0xb8, 0x35, 0x7a, 0xa9, 0x12, + 0x56, 0x2d, 0xe4, 0xbb, 0x2d, 0xc8, 0x98, 0x0e, + 0x35, 0x9e, 0xea, 0x14, 0x43, 0x80, 0xde, 0x9e, + 0x2e, 0xf8, 0xf9, 0xcd, 0x61, 0xa6, 0x22, 0xc8, + 0x77, 0xfc, 0x32, 0x71, 0x4b, 0xcb, 0x00, 0x9b, + 0x9f, 0x85, 0x02, 0x92, 0xfa, 0x84, 0xd8, 0xd8, + 0x09, 0xa4, 0x08, 0xc1, 0x96, 0xd3, 0x9a, 0x27, + 0xa3, 0x82, 0x05, 0xd0, 0x78, 0x18, 0x0a, 0x7d, + 0xb6, 0x95, 0xc0, 0x27, 0x3e, 0x76, 0x77, 0xf3, + 0xd9, 0x62, 0x8e, 0x77, 0xa0, 0x1f, 0x9e, 0x41, + 0xdb, 0x24, 0xaa, 0xdd, 0x8f, 0x94, 0x7b, 0x1f, + 0xff, 0xaa, 0xfd, 0xe2, 0x19, 0xc2, 0x71, 0x80, + 0x0a, 0xda, 0xc5, 0x98, 0x57, 0xde, 0x4e, 0xfb, + 0x38, 0xe6, 0x9b, 0xe5, 0xa6, 0x1f, 0x7d, 0x2c, + 0x41, 0x5f, 0x4d, 0x13, 0xb8, 0x0c, 0xac, 0x9a, + 0x7d, 0xc0, 0x7c, 0x44, 0x64, 0x1e, 0xbc, 0x7d, + 0x16, 0xaa, 0x45, 0xda, 0x62, 0x4e, 0x64, 0x69, + 0xd6, 0x71, 0x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xdf, 0x83, + 0xd5, 0xc2, 0x7f, 0xe8, 0x5f, 0x4a, 0x36, 0x0a, + 0x6d, 0x3c, 0x91, 0x8e, 0x52, 0xf3, 0xdd, 0x62, + 0xff, 0x78, 0x87, 0xd9, 0x4c, 0xad, 0x5c, 0x9f, +}; + +/* + * IV method encblkno8, blkno 3. + */ +static const uint8_t bf_cbc_128_encblkno8_vec3_ctxt[SECSIZE] = { + 0xa3, 0x9a, 0x21, 0xbd, 0x1c, 0x97, 0x4f, 0xe2, + 0x7d, 0x63, 0xfe, 0x52, 0x07, 0xac, 0x81, 0x75, + 0x15, 0x04, 0x8c, 0xc7, 0x7c, 0x11, 0x8d, 0x53, + 0x17, 0x87, 0xe8, 0x5d, 0xb1, 0xe8, 0xcb, 0x43, + 0xe2, 0x4b, 0xce, 0x9b, 0xf7, 0x51, 0x0a, 0xee, + 0x0a, 0x49, 0xae, 0x9a, 0xbd, 0x33, 0x3f, 0x0b, + 0xd4, 0xe8, 0x57, 0x77, 0xb1, 0xe1, 0xa5, 0x22, + 0x83, 0xbf, 0x7c, 0x63, 0x6c, 0x3b, 0x25, 0xde, + 0x2c, 0x6a, 0x28, 0x66, 0x0e, 0xc4, 0x8d, 0x66, + 0x66, 0xb6, 0xc6, 0xb5, 0x38, 0x40, 0x84, 0x81, + 0xec, 0x03, 0xdb, 0xbf, 0xe1, 0x8f, 0xf4, 0xb3, + 0xc4, 0x50, 0x24, 0xa2, 0x48, 0x66, 0x73, 0xed, + 0x4b, 0x00, 0x12, 0xd5, 0x15, 0x5f, 0xfb, 0xd9, + 0x6c, 0x76, 0x3b, 0xa2, 0x68, 0x41, 0xc1, 0x96, + 0x50, 0xff, 0x8a, 0x83, 0xac, 0x02, 0x42, 0xcb, + 0xed, 0x93, 0xbf, 0xd9, 0x51, 0x46, 0x50, 0xd1, + 0xeb, 0x02, 0x61, 0x64, 0xa7, 0x0e, 0x95, 0xc2, + 0x95, 0x5a, 0x93, 0xd9, 0x77, 0x17, 0xa4, 0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x74, 0xed, + 0xfc, 0x85, 0x53, 0x01, 0x87, 0xa7, 0xa0, 0x1f, +}; + +const struct testvec bf_cbc_128_8_vectors[] = { + { + .blkno = 0, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_128_encblkno8_vec0_ctxt, + }, + { + .blkno = 1, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_128_encblkno8_vec1_ctxt, + }, + { + .blkno = 2, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_128_encblkno8_vec2_ctxt, + }, + { + .blkno = 3, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_128_encblkno8_vec3_ctxt, + }, +}; + +/* + * IV method encblkno1, blkno 0. + */ +static const uint8_t bf_cbc_256_encblkno1_vec0_ctxt[SECSIZE] = { + 0x14, 0xec, 0xa9, 0xa0, 0x51, 0x9f, 0x5e, 0xb5, + 0x81, 0x6f, 0xa2, 0xbf, 0x5e, 0xf7, 0x91, 0xad, + 0xc5, 0x1a, 0x7e, 0xe6, 0x7a, 0x82, 0x4a, 0xba, + 0x54, 0x60, 0xcb, 0xc3, 0x2f, 0x69, 0x5c, 0xd9, + 0x1e, 0x58, 0xa1, 0x88, 0xa1, 0xe5, 0xa8, 0x52, + 0xdf, 0xf3, 0x8d, 0x5e, 0x2f, 0x81, 0x54, 0xab, + 0x67, 0xb5, 0x05, 0x63, 0x20, 0x10, 0x98, 0xf5, + 0xa5, 0xc3, 0x9e, 0x6d, 0x80, 0x4d, 0xb6, 0x82, + 0x80, 0x5e, 0xb3, 0xc5, 0xd8, 0x77, 0x94, 0xa0, + 0xb8, 0x67, 0xb8, 0x2d, 0x9b, 0x11, 0x3c, 0x24, + 0xbd, 0xb7, 0x0b, 0x1d, 0xeb, 0x1d, 0x6c, 0xab, + 0x3f, 0x8c, 0x91, 0xa0, 0x3a, 0xa6, 0x0c, 0x5a, + 0x88, 0xa0, 0xb5, 0xea, 0x49, 0x58, 0xfb, 0x37, + 0x7c, 0x94, 0xc4, 0x22, 0x35, 0x84, 0xda, 0xd1, + 0x1b, 0x4a, 0x42, 0xa1, 0xd4, 0x90, 0xcd, 0xfb, + 0x77, 0x29, 0xd2, 0xe3, 0x89, 0xec, 0x9e, 0x6a, + 0x4b, 0xbc, 0xc0, 0xfa, 0xb8, 0xdd, 0x5c, 0x2b, + 0xc5, 0x49, 0xb1, 0x6d, 0x6f, 0x2c, 0xb5, 0x50, + 0xd1, 0xd4, 0x9b, 0x15, 0x1c, 0xd7, 0x44, 0xf3, + 0x2e, 0x1f, 0x46, 0xee, 0x38, 0x40, 0xaa, 0x73, + 0xca, 0xf2, 0xc3, 0x83, 0xe2, 0xff, 0xd6, 0xc7, + 0x20, 0xea, 0x70, 0x95, 0x48, 0x58, 0x29, 0x6e, + 0xac, 0x10, 0x75, 0x69, 0x1d, 0xb2, 0x08, 0x3e, + 0x68, 0x43, 0xff, 0x69, 0x1e, 0x88, 0x0a, 0x34, + 0x40, 0xae, 0xb9, 0xf4, 0xb9, 0x3f, 0xa5, 0xd2, + 0xfb, 0xa0, 0xfd, 0x10, 0xa5, 0xbb, 0xd7, 0x22, + 0x8c, 0xd1, 0xf5, 0xc4, 0x11, 0xc6, 0x1e, 0xb5, + 0xfc, 0x90, 0x84, 0xa2, 0x49, 0x38, 0x64, 0x92, + 0x6e, 0xf2, 0xaa, 0xed, 0xe8, 0x9d, 0xac, 0x86, + 0xb7, 0xb3, 0xd9, 0x98, 0x11, 0x8f, 0x51, 0x33, + 0x84, 0x06, 0x40, 0x26, 0x3f, 0xe1, 0xb3, 0x4a, + 0x76, 0x53, 0x68, 0x8b, 0xfe, 0x6f, 0xcd, 0x66, + 0x92, 0x24, 0x42, 0xf4, 0x11, 0x02, 0x01, 0x00, + 0xaa, 0x15, 0x35, 0x42, 0xab, 0x6f, 0x2b, 0x3b, + 0x9a, 0x23, 0x73, 0x18, 0xa8, 0x9b, 0x43, 0x4b, + 0xfb, 0xef, 0x07, 0x75, 0xd7, 0xd6, 0x08, 0x94, + 0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d, 0x55, 0x12, 0xbf, + 0xe1, 0xd2, 0x7c, 0x51, 0x65, 0x8c, 0xc3, 0x8a, + 0x73, 0x2f, 0x1c, 0xd8, 0x13, 0x4a, 0xd1, 0x78, + 0xb2, 0xc8, 0x19, 0x09, 0xce, 0x7b, 0xb6, 0x77, + 0xcc, 0xc3, 0xe6, 0xee, 0x3a, 0x82, 0xf9, 0xc6, + 0x5a, 0x36, 0x46, 0xc0, 0x25, 0xee, 0xaf, 0x78, +}; + +/* + * IV method encblkno1, blkno 1. + */ +static const uint8_t bf_cbc_256_encblkno1_vec1_ctxt[SECSIZE] = { + 0x0b, 0xb6, 0x26, 0x92, 0x1d, 0x74, 0xc2, 0x10, + 0xb5, 0x99, 0x5f, 0x62, 0x7f, 0x3b, 0x49, 0x10, + 0xc1, 0x20, 0x9f, 0x38, 0x25, 0x0f, 0x59, 0xde, + 0xe4, 0xc8, 0xb5, 0x27, 0xb1, 0xec, 0x96, 0x40, + 0xe8, 0x05, 0x15, 0x40, 0x96, 0xe0, 0xff, 0xaf, + 0x53, 0x73, 0xa1, 0xa6, 0x73, 0x03, 0xcf, 0x1f, + 0x87, 0x48, 0x7d, 0x81, 0x0e, 0x35, 0x23, 0x7b, + 0xde, 0x12, 0xd8, 0xcd, 0x0a, 0xcb, 0x03, 0xc5, + 0x07, 0xf7, 0x7a, 0x04, 0xf3, 0xda, 0x7d, 0x3b, + 0x73, 0xc6, 0x31, 0xbc, 0x24, 0xde, 0x23, 0x05, + 0x3a, 0xdc, 0xe2, 0x96, 0x85, 0x06, 0xeb, 0x89, + 0xb0, 0x49, 0x3c, 0x79, 0x8e, 0xcf, 0x49, 0x0e, + 0x34, 0x04, 0xa5, 0xcf, 0x45, 0x56, 0xb6, 0xc2, + 0xf1, 0xf1, 0xab, 0x7c, 0x8a, 0xfc, 0xeb, 0xa0, + 0x8a, 0xe6, 0x73, 0xb4, 0xc3, 0x0c, 0x03, 0x5f, + 0x03, 0x53, 0x6f, 0x69, 0xa2, 0xd0, 0xa7, 0x48, + 0xc4, 0x11, 0x88, 0x75, 0xe1, 0xf3, 0xd0, 0x72, + 0x98, 0x6f, 0x84, 0xa6, 0xa8, 0x35, 0xbb, 0xac, + 0x4d, 0xac, 0x55, 0x88, 0x85, 0x86, 0x5a, 0xd9, + 0xb6, 0x57, 0xf9, 0x40, 0xf6, 0x7f, 0x1b, 0x4e, + 0x87, 0xc0, 0x56, 0x8a, 0x2f, 0x3a, 0xe5, 0xa6, + 0x67, 0x68, 0x21, 0x2b, 0xea, 0xfa, 0xee, 0x47, + 0xa0, 0x34, 0x56, 0x7d, 0xa0, 0x3d, 0x58, 0xd7, + 0xff, 0xa2, 0xb6, 0x03, 0x52, 0x16, 0xa5, 0x15, + 0x65, 0xdb, 0xe1, 0x1b, 0xdf, 0x69, 0xb1, 0x48, + 0x6a, 0xdf, 0xc1, 0x00, 0x07, 0xdc, 0x46, 0x4b, + 0x59, 0xcf, 0x15, 0x6b, 0xee, 0x4f, 0x72, 0x77, + 0x6e, 0xbf, 0x47, 0x0e, 0x84, 0x0b, 0xb1, 0xac, + 0x85, 0xce, 0x2b, 0x47, 0x7a, 0xcc, 0x30, 0x0c, + 0x2f, 0x10, 0x27, 0xaa, 0x83, 0x3f, 0x17, 0x39, + 0x84, 0x45, 0x8c, 0xb7, 0x31, 0xb3, 0x7c, 0xcd, + 0xed, 0x86, 0x7d, 0xa9, 0x06, 0x25, 0x1f, 0xe3, + 0x9a, 0x9b, 0x92, 0xdd, 0x07, 0x63, 0x3b, 0x51, + 0x32, 0x2e, 0xae, 0xdf, 0xad, 0xd4, 0x54, 0x5d, + 0x71, 0x36, 0xe9, 0xda, 0x70, 0xe9, 0xec, 0x75, + 0x0b, 0xbb, 0xcc, 0x5d, 0xc5, 0x45, 0x8e, 0x56, + 0x12, 0x87, 0x95, 0x0f, 0x0f, 0x5b, 0x22, 0xc2, + 0xe9, 0x71, 0xf2, 0x7e, 0x7b, 0xc2, 0xce, 0x1f, + 0xb4, 0x43, 0x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, 0x50, + 0xe8, 0x9e, 0xc2, 0x51, 0x4f, 0x03, 0xcd, 0x9f, + 0x36, 0x27, 0xca, 0xa2, 0x98, 0x87, 0x5a, 0xae, + 0xd8, 0x87, 0x76, 0xb6, 0xb6, 0x19, 0x7d, 0x75, +}; + +/* + * IV method encblkno1, blkno 2. + */ +static const uint8_t bf_cbc_256_encblkno1_vec2_ctxt[SECSIZE] = { + 0x91, 0x45, 0x4e, 0xe8, 0xad, 0xe3, 0x95, 0x0f, + 0x40, 0x35, 0x21, 0x21, 0x77, 0x62, 0x1d, 0x65, + 0xe4, 0x93, 0x11, 0xd2, 0x20, 0xa4, 0xe4, 0x53, + 0x44, 0xff, 0x60, 0xe9, 0x34, 0xb2, 0x33, 0x87, + 0x3d, 0xb0, 0xd8, 0x37, 0x7e, 0x0e, 0x9a, 0x53, + 0x92, 0xeb, 0xee, 0x16, 0x41, 0x25, 0xe3, 0x80, + 0x0c, 0x53, 0xd8, 0x1f, 0xf0, 0x99, 0xcb, 0x31, + 0xd1, 0x00, 0x82, 0x03, 0xcc, 0xa9, 0x5c, 0x8d, + 0x1a, 0xbb, 0x03, 0x81, 0x80, 0x0d, 0x5d, 0x4a, + 0x96, 0x74, 0x79, 0xf4, 0xa7, 0x46, 0x97, 0x42, + 0x5e, 0xb6, 0x8d, 0xc1, 0x95, 0x1d, 0x98, 0x4d, + 0xe5, 0xe9, 0x70, 0x1a, 0x5a, 0xad, 0xf4, 0x3d, + 0xe1, 0xa7, 0x25, 0xc7, 0xfa, 0x0a, 0x75, 0x98, + 0x2f, 0xef, 0x16, 0x2e, 0xf2, 0x02, 0x8a, 0x4c, + 0x1f, 0x5a, 0xbb, 0x06, 0x1b, 0x4e, 0x50, 0xfb, + 0x03, 0xed, 0x2a, 0x53, 0xdc, 0x2a, 0x65, 0xad, + 0x57, 0x84, 0x48, 0xdb, 0xd2, 0x9b, 0xc0, 0x01, + 0x5f, 0x7d, 0x3e, 0x84, 0xe5, 0x15, 0x7d, 0xc5,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0x07, 0xde, 0x46, 0x28, 0xc1, + 0x2c, 0x15, 0xa2, 0x34, 0xea, 0xe7, 0xc3, 0x36, + 0xe6, 0x18, 0x20, 0x4e, 0x20, 0x3f, 0x32, 0xa8, + 0x29, 0x05, 0xf6, 0xa5, 0xf2, 0xa3, 0xeb, 0x7a, + 0x25, 0x5e, 0x14, 0x1f, 0xd0, 0xe1, 0x8e, 0xfb, + 0x28, 0xc5, 0xa2, 0x42, 0xed, 0x4c, 0x12, 0x15, + 0x2a, 0x08, 0xfb, 0x0b, 0xfb, 0x94, 0x64, 0xc0, + 0x8b, 0xbb, 0xbb, 0x2c, 0xef, 0xab, 0x0b, 0x4c, + 0x27, 0x40, 0x94, 0x3e, 0x93, 0x77, 0x98, 0xcc, + 0x64, 0xe3, 0xba, 0x22, 0x95, 0xd7, 0xc1, 0xe3, + 0xa7, 0xcd, 0xf9, 0x25, 0xdc, 0xc4, 0xd2, 0xee, + 0x5b, 0x53, 0x72, 0x59, 0x8b, 0xea, 0xbf, 0xde, + 0x2b, 0x35, 0xd5, 0x27, 0x57, 0x2e, 0x13, 0xa7, + 0x50, 0x2d, 0xa5, 0xd5, 0x43, 0x0b, 0x49, 0x87, + 0xd0, 0xbd, 0xdd, 0xec, 0x4b, 0xd1, 0x8b, 0xf6, + 0xf6, 0xd0, 0x97, 0xcb, 0x8d, 0x58, 0x35, 0x27, + 0xa5, 0x7e, 0x4a, 0xda, 0x93, 0xa4, 0x1e, 0x39, + 0x53, 0x59, 0x87, 0xfe, 0x82, 0x09, 0xda, 0x03, + 0x33, 0xcf, 0x94, 0x60, 0xb1, 0x0c, 0xa1, 0x0e, + 0xd6, 0xaa, 0xb0, 0x09, 0x96, 0x8b, 0x72, 0x15, + 0xfb, 0xb0, 0x7d, 0x06, 0xf5, 0x2d, 0x64, 0xcd, + 0x03, 0xf0, 0xfa, 0xed, 0x6f, 0x43, 0xe3, 0xf3, + 0x33, 0xaf, 0x65, 0x82, 0x1d, 0xad, 0x03, 0x62, + 0xbe, 0x12, 0x14, 0x85, 0x66, 0x45, 0x03, 0x79, +}; + +/* + * IV method encblkno1, blkno 3. + */ +static const uint8_t bf_cbc_256_encblkno1_vec3_ctxt[SECSIZE] = { + 0x65, 0xbb, 0x30, 0x13, 0x9a, 0x26, 0xe9, 0x3d, + 0x54, 0x28, 0x77, 0xf1, 0x3f, 0x9b, 0xe1, 0x3e, + 0x70, 0x90, 0x6f, 0x16, 0xfc, 0x2f, 0x27, 0xb3, + 0xc6, 0x3c, 0x38, 0x31, 0x11, 0xe1, 0x3b, 0x72, + 0x22, 0x1c, 0x01, 0xc5, 0xa6, 0x70, 0x16, 0x4d, + 0xd2, 0xbd, 0xcb, 0x15, 0x00, 0x22, 0xab, 0x65, + 0x6a, 0x96, 0x5e, 0x45, 0x7f, 0xfd, 0x76, 0x18, + 0x43, 0x25, 0x75, 0x73, 0xa4, 0x24, 0xe4, 0x5b, + 0xca, 0xf7, 0x6f, 0xfe, 0xc6, 0x4c, 0x81, 0x77, + 0xe5, 0x1b, 0xb4, 0x7b, 0x64, 0xc2, 0x0d, 0x2b, + 0xa9, 0x76, 0xae, 0x5d, 0xab, 0x81, 0x77, 0xa6, + 0x48, 0xe9, 0x0c, 0x6d, 0x93, 0xbd, 0x7e, 0xdc, + 0x39, 0x89, 0x72, 0xd2, 0x07, 0x87, 0x44, 0xa6, + 0x7d, 0x08, 0x54, 0xc6, 0x90, 0x1d, 0xa2, 0xd7, + 0xfd, 0xd5, 0x59, 0x67, 0xd9, 0x5f, 0x5c, 0xbc, + 0x60, 0xc7, 0xf6, 0x98, 0xad, 0x21, 0xdf, 0xde, + 0x27, 0xca, 0x73, 0x2f, 0x56, 0xb7, 0xd7, 0x54, + 0x6e, 0xc3, 0x09, 0x6f, 0x1b, 0x82, 0x6f, 0xf8, + 0x1b, 0xb2, 0x54, 0x47, 0x54, 0x55, 0x67, 0x1c, + 0x4a, 0x10, 0x44, 0xb8, 0x8e, 0x85, 0x71, 0x70, + 0x02, 0x49, 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x15, 0x3b, + 0x88, 0x9a, 0x33, 0x5d, 0x68, 0x82, 0x29, 0x53, + 0x94, 0x18, 0x0d, 0x14, 0x9e, 0x5f, 0xc1, 0x32, + 0x0a, 0x95, 0x6e, 0xa3, 0x82, 0x4b, 0x58, 0x0f, + 0x9c, 0xf0, 0x26, 0x4b, 0x2f, 0x02, 0x60, 0x85, + 0xdd, 0x2c, 0xb8, 0x87, 0x8b, 0x14, 0x9c, 0x54, + 0x0a, 0x5a, 0x02, 0xbe, 0xe2, 0x71, 0xcc, 0x07, + 0xae, 0x67, 0x00, 0xa8, 0xd4, 0x09, 0x7c, 0xee, + 0x0d, 0x29, 0x17, 0x67, 0x96, 0x68, 0x41, 0xfa, + 0x72, 0x29, 0x98, 0x2b, 0x23, 0xd1, 0xa9, 0x89, + 0x1c, 0xcc, 0xaf, 0x88, 0xdb, 0xb5, 0x1e, 0xb1, + 0xae, 0x17, 0x5f, 0x29, 0x8d, 0x1c, 0x0a, 0x5c, + 0xb9, 0xa7, 0x59, 0x8b, 0x91, 0x41, 0xee, 0x89, + 0xe1, 0x0e, 0x7e, 0x0a, 0xee, 0xbc, 0x35, 0xab, + 0xf1, 0x5a, 0x58, 0x03, 0xa2, 0xcf, 0x33, 0xa3, + 0x74, 0x82, 0xd3, 0xa0, 0x32, 0xfc, 0x3b, 0x9c, + 0xdf, 0xc0, 0x3a, 0x76, 0xe1, 0xea, 0xf0, 0x6d, + 0xc8, 0xe7, 0x97, 0xec, 0x03, 0xc1, 0x72, 0x94, + 0xe5, 0xc4, 0x04, 0x2a, 0x38, 0xb4, 0xef, 0x47, + 0x1d, 0xf9, 0xb8, 0x0a, 0xa9, 0x45, 0xc1, 0x63, + 0xf8, 0x32, 0xdb, 0x5d, 0xb1, 0xa2, 0x80, 0x8c, + 0x23, 0xd3, 0x60, 0xfb, 0xf8, 0x84, 0x57, 0x8b, +}; + +const struct testvec bf_cbc_256_1_vectors[] = { + { + .blkno = 0, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_256_encblkno1_vec0_ctxt, + }, + { + .blkno = 1, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_256_encblkno1_vec1_ctxt, + }, + { + .blkno = 2, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_256_encblkno1_vec2_ctxt, + }, + { + .blkno = 3, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_256_encblkno1_vec3_ctxt, + }, +}; + +/* + * IV method encblkno8, blkno 0. + */ +static const uint8_t bf_cbc_256_encblkno8_vec0_ctxt[SECSIZE] = { + 0x90, 0x3d, 0xd2, 0xc0, 0xd3, 0x75, 0xe8, 0x04, + 0x34, 0x66, 0x76, 0x25, 0x70, 0xde, 0x41, 0xf1, + 0x35, 0x63, 0x5c, 0xac, 0x8f, 0x28, 0x17, 0xd3, + 0xae, 0x43, 0xfd, 0x8a, 0xb8, 0xc2, 0xd3, 0x88, + 0xef, 0xfa, 0x21, 0xeb, 0xb4, 0x33, 0x75, 0x69, + 0x7d, 0xe9, 0x27, 0x1c, 0x03, 0xcf, 0x90, 0xcf, + 0xf0, 0xaa, 0x3e, 0x01, 0x41, 0x24, 0xdc, 0x01, + 0x5a, 0xe8, 0x92, 0xea, 0xde, 0x87, 0xbf, 0x75, + 0xe4, 0x0b, 0xf7, 0xa3, 0x42, 0x27, 0xc4, 0xde, + 0x01, 0x6f, 0x5c, 0xec, 0x6d, 0x37, 0x38, 0xd7, + 0x4f, 0x85, 0xc0, 0xc2, 0x3a, 0xa7, 0x2d, 0x15, + 0xd5, 0x1c, 0xee, 0x15, 0x13, 0x7a, 0x4e, 0x33, + 0xc7, 0x59, 0x93, 0x73, 0xe9, 0xf5, 0x39, 0xb0, + 0xad, 0x8b, 0x61, 0xca, 0x4d, 0x31, 0xaa, 0x44, + 0xf6, 0x5c, 0xb7, 0x99, 0xe5, 0x92, 0x3d, 0x47, + 0x79, 0x9b, 0x29, 0x16, 0xe1, 0x2c, 0x30, 0x8b, + 0x1e, 0x17, 0xf0, 0x91, 0x59, 0x00, 0xab, 0x6d, + 0x4d, 0xa7, 0x4d, 0x96, 0xc3, 0xe4, 0x3d, 0x17, + 0x5c, 0x8e, 0xfc, 0x59, 0x48, 0xd4, 0xdd, 0xf4, + 0xea, 0x3a, 0x68, 0xc8, 0xb1, 0x74, 0x69, 0xcb, + 0x49, 0x1a, 0xec, 0x24, 0x4e, 0x7e, 0xe9, 0xba, + 0x75, 0xfb, 0x52, 0x85, 0x75, 0xe9, 0x41, 0x9a, + 0xc6, 0x40, 0x9c, 0x92, 0x3f, 0xe8, 0x99, 0x81, + 0x84, 0x14, 0x2b, 0x62, 0x94, 0xba, 0x56, 0x00, + 0xde, 0x88, 0xe1, 0x35, 0xea, 0x25, 0x88, 0xd1, + 0xce, 0xd4, 0xfc, 0xde, 0xee, 0x1a, 0xfd, 0xb1, + 0xa7, 0x46, 0x9d, 0x0c, 0x99, 0xa6, 0xab, 0x23, + 0x55, 0x2f, 0x46, 0xd7, 0xb3, 0xcd, 0x2c, 0xab, + 0x93, 0x3e, 0xdb, 0xe2, 0x34, 0x69, 0x1a, 0x56, + 0x21, 0x92, 0x56, 0xf4, 0x05, 0xe1, 0x24, 0xee, + 0x4d, 0x5e, 0x89, 0xeb, 0x23, 0x26, 0xdc, 0x14, + 0xde, 0x56, 0x3f, 0x0c, 0x15, 0x3e, 0x42, 0x71, + 0x9b, 0xe8, 0xc5, 0xfd, 0x5e, 0x4a, 0xb6, 0xd9, + 0xa0, 0x18, 0x5d, 0xbd, 0xef, 0x80, 0xb4, 0xf6, + 0x1e, 0x56, 0x2a, 0x57, 0x13, 0xba, 0x24, 0xa4, + 0x6f, 0x4c, 0xd4, 0xaa, 0x31, 0x5e, 0x69, 0x26, + 0xd2, 0xee, 0xef, 0x7f, 0x83, 0x9c, 0x8e, 0x6a, + 0x17, 0xe3, 0xda, 0xf4, 0x59, 0xad, 0x26, 0x83, + 0x53, 0x4c, 0x0d, 0x62, 0xe5, 0x9a, 0x30, 0xc5, +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9, 0xbc, 0xa8, 0x2f, 0xd6, + 0xc1, 0x5f, 0xa4, 0x57, 0x62, 0x83, 0x82, 0x8e, + 0x1e, 0xbb, 0x85, 0xf7, 0x1b, 0x2e, 0xe2, 0xb0, +}; + +/* + * IV method encblkno8, blkno 1. + */ +static const uint8_t bf_cbc_256_encblkno8_vec1_ctxt[SECSIZE] = { + 0x2b, 0xf6, 0xd4, 0x61, 0x3b, 0x1f, 0x5b, 0xe9, + 0x32, 0xab, 0x27, 0xa1, 0xaf, 0x5e, 0xf4, 0xa7, + 0xaa, 0xc5, 0x2a, 0x3c, 0x0d, 0x34, 0xd8, 0xb3, + 0xfd, 0xb2, 0xca, 0xfb, 0x3c, 0x38, 0x96, 0x71, + 0x47, 0xaa, 0xa7, 0x2f, 0x48, 0x2c, 0x39, 0x88, + 0x2d, 0xc6, 0xb1, 0xf7, 0xc7, 0x2d, 0xda, 0xe9, + 0xfb, 0x4f, 0x9b, 0x1f, 0xe1, 0x0c, 0x24, 0x89, + 0xfe, 0x70, 0xe0, 0xb2, 0x51, 0x89, 0x51, 0xa9, + 0xae, 0xd1, 0x92, 0x4f, 0x56, 0x5c, 0x2a, 0xf4, + 0xbc, 0x4e, 0x77, 0x4a, 0xb8, 0xab, 0x02, 0x76, + 0xef, 0x69, 0xfb, 0x5e, 0x06, 0xb5, 0xff, 0x31, + 0xce, 0x2b, 0xfc, 0x48, 0x4c, 0x82, 0xe9, 0x3c, + 0x61, 0x69, 0x68, 0x1d, 0xb1, 0xc6, 0x40, 0x10, + 0xd7, 0x0e, 0xd2, 0x26, 0x33, 0x5b, 0x0b, 0xe7, + 0xc2, 0xbe, 0xf4, 0x24, 0x1a, 0xa6, 0x70, 0x31, + 0xa7, 0x15, 0x76, 0xc7, 0x90, 0x8d, 0x60, 0xe0, + 0xee, 0x5b, 0x73, 0xa9, 0xe1, 0xe1, 0xaf, 0xf0, + 0x5e, 0x6f, 0x32, 0x98, 0x92, 0xbe, 0x24, 0x81, + 0x26, 0x9f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+ 0x70, 0xe6, 0x8f, 0x35, 0x96, 0xe0, 0x11, 0x00, +}; + +/* + * IV method encblkno8, blkno 2. + */ +static const uint8_t bf_cbc_256_encblkno8_vec2_ctxt[SECSIZE] = { + 0x28, 0x93, 0x0f, 0x23, 0xfb, 0xa4, 0x9e, 0xe5, + 0x11, 0x38, 0x2b, 0xbd, 0x8d, 0x2d, 0xdb, 0x11, + 0xfa, 0xac, 0x74, 0x28, 0x95, 0x29, 0xf2, 0x92, + 0x8d, 0x00, 0x8a, 0x8a, 0x04, 0x92, 0x92, 0x33, + 0x8c, 0x4b, 0x29, 0x8e, 0xde, 0x59, 0xf4, 0x72, + 0xae, 0x2f, 0xe4, 0xe9, 0xd4, 0xe4, 0xb6, 0x69, + 0xc5, 0x1b, 0xbe, 0x02, 0x85, 0x4b, 0x24, 0x1e, + 0x79, 0xb9, 0x22, 0x29, 0x4c, 0x60, 0x8c, 0xc5, + 0x03, 0x1d, 0x79, 0xfe, 0x3d, 0x9e, 0x47, 0xb6, + 0xf7, 0x17, 0x65, 0x24, 0x15, 0x5d, 0x75, 0x4d, + 0xdb, 0xbc, 0x68, 0x67, 0x3b, 0xc3, 0x5a, 0x7e, + 0x9d, 0x98, 0x67, 0xe4, 0x8f, 0x9a, 0xd1, 0x31, + 0xe0, 0x26, 0xa1, 0x68, 0xbe, 0x53, 0x73, 0x7c, + 0xfd, 0xce, 0x6c, 0xd6, 0x1f, 0x51, 0xe6, 0x84, + 0x54, 0x7a, 0xe3, 0x7f, 0x7c, 0x8f, 0x2f, 0x88, + 0x58, 0xfe, 0x5e, 0x82, 0x11, 0xc9, 0xa5, 0x89, + 0xa4, 0x49, 0x92, 0x21, 0x0f, 0x03, 0xdb, 0x16, + 0xc4, 0xc0, 0x80, 0xb7, 0x16, 0x4c, 0x29, 0xbe, + 0x18, 0xfa, 0x2d, 0xdf, 0x4a, 0x23, 0x34, 0x9a, + 0x27, 0xea, 0xed, 0x95, 0x25, 0x14, 0xa8, 0x2e, + 0x17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0x49, 0x4a, 0xfe, 0x8f, + 0xaa, 0x57, 0x3a, 0x0c, 0x59, 0x69, 0xe7, 0xb8, + 0xfc, 0x71, 0x5c, 0x4f, 0x18, 0x12, 0xe5, 0xef, + 0xdb, 0x1f, 0x66, 0x9a, 0xe2, 0x1a, 0x92, 0x1f, + 0xfe, 0x20, 0x81, 0xe5, 0x83, 0x97, 0xfb, 0xaf, + 0xeb, 0x31, 0x6c, 0x81, 0xf2, 0x2f, 0xf4, 0x41, + 0xf1, 0xd9, 0x61, 0xfb, 0x36, 0x4e, 0xab, 0xc5, + 0x8b, 0x9c, 0x37, 0xea, 0x88, 0xeb, 0x1e, 0x4c, + 0x84, 0x1a, 0xac, 0x4c, 0x19, 0x39, 0x51, 0x53, + 0xe0, 0x50, 0xb0, 0xdf, 0xe6, 0xc5, 0xbb, 0x80, + 0x06, 0x30, 0x14, 0xf5, 0x0e, 0x73, 0xd2, 0xdb, + 0x19, 0x45, 0x30, 0xdc, 0xd0, 0x4d, 0xe6, 0xd6, + 0x0e, 0x2d, 0x77, 0xa3, 0xb3, 0x27, 0xda, 0x99, + 0x62, 0x88, 0x35, 0xba, 0x64, 0x15, 0xec, 0xaf, + 0x70, 0x97, 0x94, 0x81, 0x30, 0x6d, 0x63, 0x42, + 0x71, 0x3e, 0x06, 0xec, 0x50, 0x96, 0x87, 0x59, + 0xe7, 0x26, 0x9c, 0xcf, 0xc7, 0xe7, 0x62, 0x82, + 0x3b, 0xd7, 0xfe, 0xb4, 0x48, 0x45, 0x9d, 0x54, + 0x18, 0x15, 0x13, 0x74, 0x92, 0x6f, 0x43, 0xb3, + 0xa9, 0x82, 0xd4, 0xc2, 0xef, 0x61, 0x9d, 0x5e, + 0x1d, 0xc6, 0x80, 0xd3, 0xe9, 0xdd, 0x52, 0x9c, + 0x4d, 0x04, 0x05, 0xa0, 0x43, 0x36, 0xb6, 0x89, +}; + +/* + * IV method encblkno8, blkno 3. + */ +static const uint8_t bf_cbc_256_encblkno8_vec3_ctxt[SECSIZE] = { + 0x60, 0x91, 0x19, 0x89, 0xee, 0xac, 0x12, 0xe5, + 0x60, 0x6c, 0xfd, 0xf9, 0xe4, 0xc6, 0xc9, 0xbd, + 0x75, 0xe1, 0xa5, 0xe6, 0xf4, 0xed, 0x4b, 0xf4, + 0x16, 0xf4, 0x57, 0xa4, 0xe6, 0x60, 0x8e, 0x1b, + 0x97, 0x0e, 0xd5, 0x09, 0xa1, 0x3c, 0x6c, 0xe8, + 0x91, 0xaf, 0x19, 0x96, 0x2a, 0x7b, 0x77, 0x30, + 0xc7, 0x99, 0xe6, 0xaa, 0xb0, 0xe2, 0x29, 0x1c, + 0x39, 0x54, 0x1c, 0x0a, 0x4a, 0x51, 0xa2, 0xa2, + 0x22, 0x96, 0x05, 0x8b, 0x12, 0x80, 0x16, 0x28, + 0xdc, 0xfa, 0x22, 0x90, 0xa4, 0x33, 0xb1, 0x84, + 0x13, 0x52, 0x5d, 0xb5, 0xd4, 0xe8, 0x60, 0x18, + 0x6a, 0xb8, 0x1b, 0xdb, 0xb4, 0x69, 0xf6, 0x09, + 0x95, 0x71, 0xdd, 0x43, 0x21, 0xad, 0x7e, 0xf7, + 0x8e, 0x7a, 0x0d, 0xf0, 0x52, 0x54, 0xb8, 0xdc, + 0x7d, 0x72, 0x29, 0x97, 0x2b, 0x9c, 0x2c, 0xef, + 0xc3, 0x26, 0x68, 0x72, 0xae, 0x29, 0x0f, 0x67, + 0xbf, 0xea, 0x92, 0x27, 0xd1, 0xba, 0x8d, 0x32, + 0x8b, 0x26, 0x91, 0x30, 0x88, 0xcc, 0x47, 0xaf, + 0x54, 0x8c, 0x88, 0x88, 0x2f, 0x59, 0x76, 0x34, + 0x43, 0x35, 0x44, 0xc3, 0x16, 0x28, 0x62, 0x4b, + 0xbb, 0x47, 0x99, 0x7c, 0x26, 0x51, 0xe2, 0x7d, + 0xd8, 0x2c, 0x35, 0xf4, 0x24, 0xf1, 0x5b, 0x01, + 0xcc, 0x9a, 0x54, 0xd8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dd, + 0x92, 0x2b, 0x23, 0xc6, 0x59, 0x19, 0xda, 0x9a, + 0x01, 0x9c, 0x5c, 0xc1, 0xaa, 0xcf, 0x6d, 0xd0, + 0xa5, 0x06, 0xc7, 0x5e, 0x6b, 0x60, 0x64, 0x9f, + 0xfe, 0xa8, 0x3f, 0x64, 0xa8, 0xed, 0xf8, 0x62, + 0xd7, 0x6d, 0x34, 0x41, 0x3e, 0x5e, 0x74, 0xc7, + 0xe6, 0x62, 0xb1, 0x5a, 0xec, 0x6a, 0xc1, 0x71, + 0x19, 0xf3, 0xf1, 0xe7, 0x46, 0x13, 0xd6, 0xb6, + 0x5a, 0xf4, 0xca, 0x3f, 0xe3, 0xa1, 0x1f, 0xe4, + 0xda, 0xd6, 0x0c, 0x62, 0x6a, 0x33, 0x42, 0x99, + 0x6f, 0x5d, 0x3a, 0xe0, 0xe7, 0xfa, 0x2d, 0x47, + 0x4a, 0xec, 0xaa, 0x71, 0xb5, 0xeb, 0x62, 0xb8, + 0x31, 0x34, 0x07, 0x44, 0xa2, 0x18, 0xec, 0x76, + 0xf7, 0x77, 0x56, 0x86, 0xc7, 0xe0, 0x1e, 0x8e, + 0xec, 0x16, 0x2b, 0xeb, 0xff, 0xaa, 0xba, 0x83, + 0x1f, 0xdc, 0x32, 0x23, 0x27, 0xea, 0xea, 0x0c, + 0x3a, 0x5f, 0x2b, 0xb4, 0xee, 0x0c, 0xf2, 0x73, + 0xbb, 0x59, 0x9b, 0x73, 0xf7, 0xfa, 0xe1, 0x1f, + 0x3b, 0xdb, 0x40, 0x29, 0xf0, 0x6c, 0xbe, 0x8f, + 0x2e, 0xd0, 0x83, 0xf7, 0xe8, 0x2a, 0x81, 0x82, +}; + +const struct testvec bf_cbc_256_8_vectors[] = { + { + .blkno = 0, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_256_encblkno8_vec0_ctxt, + }, + { + .blkno = 1, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_256_encblkno8_vec1_ctxt, + }, + { + .blkno = 2, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_256_encblkno8_vec2_ctxt, + }, + { + .blkno = 3, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_256_encblkno8_vec3_ctxt, + }, +}; + +/* + * IV method encblkno1, blkno 0. + */ +static const uint8_t bf_cbc_448_encblkno1_vec0_ctxt[SECSIZE] = { + 0xb0, 0x1b, 0x43, 0xc9, 0x84, 0x53, 0x51, 0x72, + 0x1f, 0x93, 0x62, 0x94, 0x13, 0x1f, 0xe3, 0xc1, + 0x30, 0xee, 0xc4, 0x35, 0x98, 0xb8, 0x11, 0x9b, + 0xd1, 0x23, 0xfa, 0x2d, 0xc1, 0xe6, 0xf3, 0x8f, + 0x8b, 0x05, 0x8d, 0xc5, 0x1d, 0xc3, 0x29, 0x1a, + 0xff, 0x08, 0xb0, 0x97, 0x88, 0x50, 0x8f, 0x41, + 0x66, 0xc6, 0x70, 0x37, 0xca, 0xb2, 0xcd, 0x91, + 0x89, 0x41, 0x1b, 0x42, 0xce, 0x02, 0xec, 0xe8, + 0x9b, 0xf3, 0x50, 0x95, 0x5f, 0xba, 0xda, 0xd5, + 0x0c, 0x2f, 0x29, 0x2a, 0x14, 0x96, 0x4a, 0x60, + 0x04, 0x43, 0x62, 0x80, 0x89, 0xcf, 0xfd, 0xb6, + 0xc7, 0x2d, 0xb2, 0xac, 0xce, 0x51, 0xf5, 0xd1, + 0xcd, 0x41, 0x59, 0x8b, 0xf5, 0x02, 0x2d, 0xe8, + 0xc4, 0xee, 0xe9, 0x40, 0x6f, 0xcd, 0xbe, 0x3b, + 0xd0, 0x8d, 0x3e, 0x6c, 0x42, 0x2a, 0x17, 0xfd, + 0x78, 0xf6, 0xb2, 0xde, 0x69, 0x81, 0xbb, 0xae, + 0xd9, 0x1f, 0x49, 0xa6, 0x4c, 0x5a, 0xe9, 0x94, + 0x49, 0x9b, 0x7e, 0x32, 0x6d, 0x11, 0xea, 0x88, + 0xda, 0xf0, 0xc7, 0x8d, 0x07, 0x98, 0xab, 0xc7, + 0xf3, 0xcf, 0x2e, 0xda, 0x27, 0x44, 0x68, 0xc7, + 0xdc, 0xda, 0x00, 0xd0, 0x6d, 0x64, 0x5b, 0x39, + 0x46, 0x3d, 0x98, 0x24, 0xee, 0x3b, 0x36, 0x23, + 0x62, 0xf6, 0x8e, 0xb9, 0x8d, 0xc1, 0x9a, 0x7b, + 0xd7, 0x03, 0x6b, 0xb7, 0x81, 0x19, 0xec, 0x2f, + 0x0c, 0x0b, 0x32, 0x5a, 0xb3, 0x25, 0xf5, 0xcc, + 0xa3, 0x60, 0xe6, 0x4e, 0x03, 0xcd, 0xdc, 0x67, + 0xe5, 0x26, 0xda, 0xe0, 0x1f, 0x33, 0x99, 0xc3, + 0x43, 0x8c, 0x9c, 0x1a, 0x85, 0xb1, 0x15, 0x04, + 0xc1, 0x06, 0xd1, 0x2d, 0xc9, 0x67, 0x72, 0xe7, + 0xd6, 0x6d, 0x1f, 0x22, 0x56, 0x56, 0xfa, 0x8a, + 0xd7, 0x16, 0x37, 0x3f, 0x3e, 0x67, 0xa5, 0xb7, + 0xee, 0x3e, 0xd2, 0x38, 0xd5, 0xce, 0xa9, 0x62, + 0x82, 0x17, 0xae, 0xae, 0x62, 0xe6, 0xb7, 0xf2, + 0x73, 0xf1, 0xc1, 0xb7, 0xe9, 0x62, 0x79, 0x3b, + 0x3b, 0x3f, 0xaa, 0x0d, 0x42, 0x03, 0x35, 0x3f, + 0x5d, 0xa4, 0xba, 0x02, 0x23, 0x65, 0x40, 0x0e, + 0x61, 0x31, 0xc9, 0xd5, 0x79, 0x36, 0x76, 0x7c, + 0x21, 0x4a, 0x75, 0xb2, 0xa0, 0x2b, 0xc1, 0xb8, + 0xba, 0xf8, 0x10, 0x7a, 0x85, 0x32, 0x81, 0xbf, + 0x2d, 0x58, 0x3c, 0x22, 0x2f, 0x0b, 0xce, 0x03, + 0x12, 0xce, 0x13, 0xce, 0x4a, 0x81, 0x77, 0x1d, + 0x68, 0x99, 0xc0, 0x25, 0xeb, 0xd9, 0x80, 0x0d, + 0xe7, 0x17, 0xc8, 0x41, 0xbd, 0x4b, 0x9c, 0xdd, + 0x41, 0x74, 0x90, 0x2a, 0x65, 0x92, 0x05, 0xff, + 0x06, 0x24, 0xeb, 0x89, 0xd8, 0x41, 0xaa, 0x41, + 0xac, 0x8a, 0x31, 0xc6, 0x82, 0x44, 0x12, 0x5a, + 0xd9, 0x1c, 0xca, 0x76, 0x2b, 0x4e, 0xe8, 0x18, + 0x7e, 0x50, 0xf5, 0x8c, 0x7c, 0x11, 0xe7, 0x0e, + 0xfd, 0x08, 0x5e, 0x64, 0x8b, 0x5b, 0x9f, 0x94, + 0x8b, 0x0d, 0x83, 0x7e, 0xef, 0x89, 0x30, 0x4a, + 0x55, 0xce, 0x10, 0x5f, 0x15, 0xd2, 0xe7, 0x07, + 0x0c, 0x34, 0x92, 0xda, 0xae, 0x84, 0x26, 0x28, + 0x36, 0x1a, 0x96, 0xc6, 0xf1, 0x41, 0x2b, 0xb6, + 0x01, 0xfe, 0x20, 0x05, 0x43, 0x80, 0x45, 0xdf, + 0x5c, 0xc2, 0x96, 0xc8, 0x41, 0x68, 0x87, 0x78, + 0xbc, 0xf8, 0x34, 0xfb, 0x19, 0x61, 0xab, 0x7f, + 0x15, 0x56, 0x7f, 0x1a, 0xf5, 0x08, 0xf1, 0x1c, + 0x59, 0x70, 0x92, 0x3a, 0xda, 0x1a, 0xfd, 0xfc, + 0x4d, 0xe1, 0x12, 0x61, 0xc1, 0xd8, 0xdb, 0x63, + 0x6e, 0x6b, 0x19, 0x96, 0x68, 0x17, 0x9b, 0xf5, + 0xa9, 0x5d, 0x2c, 0xaf, 0xad, 0xc6, 0x26, 0x9e, + 0x09, 0xcb, 0x67, 0x4e, 0x50, 0x7d, 0x2f, 0xae, + 0x4e, 0x73, 0xd9, 0x5a, 0xaa, 0x5d, 0x54, 0x20, + 0x7b, 0x77, 0xcf, 0xf8, 0xad, 0x88, 0x6b, 0xc8, +}; + +/* + * IV method encblkno1, blkno 1. + */ +static const uint8_t bf_cbc_448_encblkno1_vec1_ctxt[SECSIZE] = { + 0x8b, 0x2a, 0xcf, 0x7d, 0x38, 0x1b, 0xaa, 0x33, + 0x1c, 0xe6, 0xa1, 0x37, 0x6e, 0x9e, 0xb3, 0x48, + 0x2a, 0xb8, 0x61, 0x11, 0x00, 0xe5, 0x48, 0xea, + 0xb5, 0x9f, 0x6c, 0xa4, 0xdf, 0x8d, 0x5a, 0xd8, + 0x03, 0x55, 0x4d, 0x07, 0x7d, 0x5f, 0x1b, 0x18, + 0xd1, 0x86, 0x52, 0xc1, 0x13, 0xda, 0x99, 0x23, + 0xeb, 0xab, 0xb2, 0x93, 0x40, 0x7c, 0x6a, 0x8a, + 0xaa, 0xf8, 0xf1, 0x66, 0xf1, 0x10, 0x1d, 0xcd, + 0x25, 0xc7, 0x84, 0x55, 0x02, 0x1d, 0xc0, 0x3c, + 0xba, 0xf4, 0xbf, 0xe2, 0xe4, 0xc3, 0x57, 0xdc, + 0x0d, 0xfd, 0xeb, 0xb3, 0x7d, 0x31, 0x82, 0x6b, + 0x5c, 0x0e, 0x92, 0xa5, 0x42, 0x8b, 0x7f, 0x36, + 0x74, 0x4d, 0xfd, 0x2f, 0xd7, 0x19, 0x0d, 0x23, + 0xa7, 0x36, 0xe8, 0xe4, 0xe5, 0xff, 0xc8, 0x0d, + 0xe1, 0x48, 0x25, 0x79, 0xa9, 0x22, 0xac, 0x72, + 0x86, 0x28, 0xcb, 0x63, 0xa6, 0xa0, 0x46, 0x08, + 0x53, 0xb8, 0x59, 0xab, 0x0f, 0x8f, 0xb1, 0x78, + 0xf8, 0x4e, 0x6d, 0x1a, 0xb5, 0xdd, 0x12, 0x02, + 0x57, 0x55, 0xf8, 0xab, 0x78, 0x7d, 0x75, 0x61, + 0x81, 0x20, 0xd6, 0x4b, 0x7d, 0x76, 0x05, 0xc9, + 0x56, 0xf2, 0xe9, 0x3f, 0xb6, 0xb5, 0x02, 0x2b, + 0x1c, 0x29, 0xbf, 0x07, 0xe9, 0x5f, 0x9b, 0x18, + 0x38, 0x26, 0xa0, 0x09, 0xde, 0x24, 0x5b, 0x37, + 0x72, 0x74, 0xf4, 0x9f, 0x86, 0x28, 0x89, 0xb6, + 0x0c, 0x95, 0x24, 0x2f, 0x88, 0x80, 0x6a, 0xc7, + 0x3a, 0xdc, 0x89, 0xb0, 0xa3, 0xfe, 0x6e, 0x38, + 0xec, 0x0b, 0x1d, 0xbc, 0xd5, 0x90, 0x48, 0xfb, + 0xb1, 0x54, 0xac, 0x6e, 0x35, 0xb0, 0x71, 0x9e, + 0x57, 0x07, 0x81, 0x90, 0xcb, 0x63, 0xb2, 0x7f, + 0x4c, 0x81, 0xe1, 0x58, 0xda, 0x27, 0xef, 0x77, + 0xe7, 0xde, 0x96, 0x83, 0x2a, 0xb1, 0x6b, 0x08, + 0x62, 0x89, 0xdc, 0x3a, 0x3f, 0x08, 0xff, 0xdc, + 0x50, 0x3e, 0xc1, 0xe4, 0x33, 0x8b, 0xad, 0x19, + 0x90, 0x0b, 0x8e, 0xc3, 0x55, 0x77, 0xf0, 0xc2, + 0x24, 0xf9, 0x0c, 0x99, 0x84, 0xb2, 0xcc, 0x23, + 0x8c, 0xab, 0x79, 0x0d, 0xff, 0x75, 0x3a, 0xe0, + 0xc9, 0xe8, 0x1e, 0x15, 0x02, 0xd5, 0x67, 0x8e, + 0x32, 0xe3, 0x1f, 0xda, 0xfb, 0x88, 0xeb, 0xa5, + 0x23, 0xea, 0x1d, 0xaa, 0xc3, 0x62, 0x7f, 0x27, + 0x38, 0x2a, 0xf6, 0xa2, 0x6a, 0x0e, 0x05, 0xff, + 0xe4, 0x63, 0x70, 0xec, 0xf8, 0x25, 0x96, 0x08, + 0xcb, 0x22, 0x2a, 0xaa, 0xbc, 0x45, 0x04, 0xb9, + 0xbc, 0x64, 0x07, 0x09, 0x31, 0xee, 0x5f, 0x9a, + 0xb1, 0x71, 0x85, 0x10, 0x60, 0xfb, 0x3c, 0x56, + 0xeb, 0xfe, 0x91, 0xab, 0x3f, 0x09, 0x76, 0xba, + 0x3c, 0xfc, 0xa6, 0x0d, 0xce, 0x9f, 0x59, 0xd4, + 0x83, 0x8d, 0x98, 0xf5, 0x0d, 0x60, 0x1f, 0xd1, + 0x10, 0x61, 0x77, 0x0d, 0xd1, 0xcd, 0xc2, 0xc2, + 0x2c, 0x7d, 0xf6, 0x15, 0x16, 0x90, 0xc9, 0xc5, + 0x1e, 0xe9, 0xf5, 0x7b, 0xb4, 0x49, 0x47, 0x91, + 0x6a, 0x94, 0x26, 0x94, 0xb3, 0xb5, 0xa7, 0x9e, + 0xcb, 0xb1, 0x9c, 0xb7, 0x5d, 0x25, 0x3c, 0x2d, + 0x8c, 0xa8, 0xa1, 0xb1, 0x79, 0x8e, 0x60, 0xa2, + 0x3e, 0x04, 0xfa, 0x3f, 0xb4, 0x43, 0xde, 0x0a, + 0xde, 0xf4, 0x58, 0xe7, 0xd1, 0x04, 0x1d, 0xb7, + 0x1d, 0xa6, 0xcb, 0x49, 0x41, 0x30, 0xb5, 0x41, + 0xb5, 0x14, 0x19, 0xe4, 0xeb, 0x2c, 0xe2, 0xf0, + 0x66, 0x59, 0xe3, 0xc6, 0xb0, 0xd0, 0x1e, 0xaa, + 0x9f, 0xa5, 0x0b, 0xb8, 0xfd, 0xae, 0x62, 0xcf, + 0x3e, 0xe2, 0xea, 0x79, 0xc5, 0x3e, 0xcf, 0xf0, + 0x40, 0x00, 0x8c, 0x81, 0x97, 0xed, 0xac, 0xf9, + 0x61, 0x75, 0x4e, 0xd7, 0xb7, 0xb2, 0x02, 0x14, + 0x04, 0xf6, 0xbf, 0x25, 0xbe, 0x78, 0x2a, 0xea, + 0xd2, 0x61, 0xf2, 0x7e, 0x45, 0x6b, 0x20, 0xca, +}; + +/* + * IV method encblkno1, blkno 2. + */ +static const uint8_t bf_cbc_448_encblkno1_vec2_ctxt[SECSIZE] = { + 0x35, 0x34, 0x49, 0x29, 0x12, 0x3f, 0xc6, 0x2f, + 0xc9, 0x3d, 0xc9, 0x54, 0x46, 0xf3, 0x26, 0xf9, + 0x5e, 0x45, 0xb4, 0xba, 0x6d, 0x0f, 0x98, 0x53, + 0x8b, 0x7a, 0x00, 0x47, 0xb6, 0xbd, 0x70, 0x89, + 0x60, 0x8e, 0x52, 0x0b, 0xe3, 0x0a, 0xd8, 0x0e, + 0x48, 0xf3, 0xcc, 0x66, 0x8d, 0x71, 0xaa, 0x0e, + 0xc2, 0x68, 0x03, 0x05, 0xf9, 0xef, 0x1d, 0x14, + 0x5a, 0x85, 0x88, 0x70, 0x77, 0xcf, 0xe3, 0xdf, + 0x18, 0xe5, 0xfb, 0xea, 0xe1, 0xe8, 0xe0, 0x25, + 0xb2, 0x14, 0x61, 0x5d, 0x2f, 0xce, 0x61, 0xec, + 0x68, 0xc8, 0x06, 0x60, 0x41, 0xc1, 0xe3, 0x0a, + 0x5e, 0x96, 0x15, 0x9b, 0x2c, 0x5b, 0xfd, 0xba, + 0x17, 0x2e, 0x50, 0xb6, 0x68, 0x39, 0x21, 0x56, + 0x31, 0x2e, 0xb5, 0x29, 0xff, 0x4a, 0x12, 0x34, + 0x02, 0x54, 0xb1, 0x7f, 0xd8, 0x35, 0xec, 0x79, + 0x9e, 0xef, 0x62, 0xf3, 0x4b, 0x58, 0x96, 0xf1, + 0x83, 0x26, 0x57, 0x3d, 0x55, 0xb9, 0xb0, 0xa7, + 0x48, 0x65, 0x06, 0xee, 0x14, 0x88, 0xb5, 0x58, + 0xc8, 0x4d, 0x6e, 0xd8, 0x44, 0x76, 0x21, 0x16, + 0xa4, 0xdf, 0x68, 0x4b, 0xff, 0x69, 0x23, 0x66, + 0x18, 0x75, 0xe6, 0x29, 0xea, 0x95, 0x87, 0x1c, + 0xed, 0x2d, 0xbd, 0xbf, 0x22, 0x56, 0x11, 0xd5, + 0x59, 0x90, 0x24, 0xd7, 0xae, 0xda, 0x99, 0x49, + 0xe3, 0x23, 0x03, 0x24, 0x3b, 0x02, 0x49, 0x1d, + 0xa5, 0x57, 0x2f, 0xea, 0xd1, 0x6a, 0x17, 0x53, + 0x0f, 0xb3, 0xa9, 0x64, 0x8a, 0xdb, 0x62, 0x17, + 0xad, 0x5c, 0x7d, 0x56, 0x14, 0x0f, 0xfb, 0x14, + 0xbe, 0x7e, 0xa1, 0xa8, 0x27, 0xf0, 0xf0, 0x3a, + 0xe7, 0xc5, 0x26, 0x98, 0x9d, 0x29, 0xf7, 0xfd, + 0x43, 0x13, 0x34, 0xe2, 0xb8, 0x0b, 0x14, 0xe9, + 0x79, 0x66, 0x7a, 0xf2, 0xed, 0x79, 0x37, 0x16, + 0x75, 0x2b, 0xf2, 0x99, 0xa1, 0xba, 0xf1, 0xc1, + 0x61, 0x8d, 0x78, 0x46, 0x3a, 0x67, 0x58, 0x6a, + 0x55, 0x0d, 0x2e, 0x08, 0x47, 0xfc, 0x94, 0x2f, + 0x65, 0xa1, 0x1a, 0xfe, 0x05, 0xfa, 0x41, 0x00, + 0x6c, 0x42, 0xbc, 0x65, 0x37, 0xd9, 0x25, 0x9c, + 0xf4, 0x83, 0x8a, 0xdb, 0x91, 0x96, 0xc5, 0xa9, + 0x02, 0x44, 0xbc, 0x9a, 0x26, 0x9c, 0xd1, 0xfa, + 0x06, 0x8b, 0xd6, 0x40, 0x8f, 0x0a, 0xd2, 0x5b, + 0xd8, 0x57, 0xd5, 0x61, 0x1b, 0x86, 0xa6, 0x49, + 0x15, 0xe4, 0x06, 0x6c, 0x48, 0x24, 0xb8, 0xe3, + 0x23, 0xed, 0xcf, 0x39, 0x44, 0x4d, 0xf0, 0x4e, + 0x89, 0x44, 0x0d, 0x3a, 0xe6, 0x1b, 0x7c, 0x39, + 0xfd, 0x79, 0x0e, 0x78, 0xc7, 0xf6, 0xa3, 0x91, + 0x18, 0x2a, 0xfb, 0x92, 0x48, 0xcc, 0x8b, 0xbb, + 0x33, 0x07, 0x42, 0xf5, 0xd0, 0x01, 0x8b, 0x12, + 0xd9, 0x5e, 0x9d, 0xe4, 0x13, 0x99, 0x11, 0x18, + 0x86, 0x8a, 0xb7, 0xa6, 0xe2, 0x38, 0x34, 0x12, + 0x67, 0xd6, 0x4b, 0xc0, 0x23, 0x56, 0xba, 0x53, + 0xbe, 0x20, 0xe5, 0xec, 0x16, 0xf9, 0x74, 0x92, + 0x62, 0xfc, 0xb9, 0xe8, 0xa3, 0xbf, 0x3b, 0x06, + 0x76, 0xa5, 0xf5, 0x56, 0x81, 0x72, 0x50, 0xc8, + 0x55, 0x80, 0x7d, 0xe1, 0x46, 0x92, 0xa1, 0xeb, + 0x41, 0xaf, 0xce, 0x52, 0xb1, 0xb3, 0x51, 0xf2, + 0xba, 0x03, 0xb4, 0xcb, 0x16, 0xd2, 0x92, 0x3d, + 0x0c, 0x9b, 0xe9, 0xd9, 0x5d, 0xcf, 0x79, 0x05, + 0xbd, 0xe0, 0x44, 0x39, 0xf0, 0x35, 0x2d, 0x7a, + 0x31, 0x3b, 0x24, 0xb3, 0xb4, 0xa5, 0x08, 0xf5, + 0xac, 0x51, 0xf1, 0x09, 0x52, 0x14, 0xc7, 0xb5, + 0xe0, 0x65, 0x47, 0x30, 0xdd, 0xa4, 0xfd, 0x71, + 0x68, 0xa5, 0x4b, 0x00, 0x72, 0xe2, 0xc4, 0xa9, + 0x5d, 0x21, 0x6d, 0x83, 0x4e, 0x88, 0xaa, 0x76, + 0x07, 0xf0, 0xf7, 0x36, 0xa2, 0x5e, 0xd5, 0x4c, + 0x7f, 0x9b, 0x74, 0x89, 0x0a, 0x18, 0xdc, 0x9a, +}; + +/* + * IV method encblkno1, blkno 3. + */ +static const uint8_t bf_cbc_448_encblkno1_vec3_ctxt[SECSIZE] = { + 0xc3, 0xd3, 0xae, 0x7e, 0x4f, 0xbe, 0x0d, 0x50, + 0xd6, 0x63, 0x2c, 0xa2, 0xfd, 0x07, 0xf1, 0x33, + 0x2a, 0x15, 0x8f, 0xd7, 0x63, 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, 0x0d, 0x79, 0xc6, 0x14, 0x52, 0x14, 0x4b, + 0xd1, 0x8c, 0x18, 0xef, 0x1f, 0xd8, 0xe7, 0x60, + 0xf3, 0x28, 0xce, 0xf1, 0x59, 0xc8, 0x43, 0x02, + 0x0e, 0x08, 0x72, 0xe5, 0x7d, 0x5b, 0xc5, 0x80, + 0xfb, 0xca, 0x2a, 0x63, 0x8d, 0x3c, 0x54, 0x04, + 0x1e, 0xdf, 0x94, 0x53, 0xf8, 0x44, 0xe5, 0xc2, + 0x5c, 0x36, 0xc9, 0x75, 0x1c, 0xa2, 0x98, 0x3d, + 0xd6, 0xee, 0x38, 0xf9, 0xab, 0x2d, 0x1a, 0xdb, + 0x87, 0x2c, 0x86, 0xfd, 0xf9, 0xb2, 0x4d, 0x21, + 0xb7, 0xc0, 0x8f, 0x75, 0x21, 0x53, 0xc7, 0xd7, + 0x3e, 0xc6, 0x6c, 0x98, 0x2c, 0x6d, 0x44, 0x13, + 0x40, 0xea, 0xaa, 0x84, 0xd9, 0x47, 0xfd, 0x65, + 0x2c, 0x3d, 0xb0, 0x76, 0xe7, 0xdd, 0xd7, 0x06, + 0x8a, 0x79, 0xa7, 0x6c, 0x3a, 0x2d, 0x32, 0xf7, + 0xae, 0xe7, 0xd2, 0xb1, 0xf2, 0xe0, 0x3a, 0x10, + 0x19, 0xa1, 0x79, 0x7b, 0x76, 0x0b, 0xeb, 0xf3, + 0x01, 0x6e, 0x9f, 0xa1, 0x5d, 0x16, 0x09, 0xec, + 0x6b, 0x64, 0xe3, 0x96, 0xb8, 0x89, 0x99, 0x8c, + 0x77, 0xcf, 0x3f, 0x37, 0x42, 0x51, 0x82, 0x5a, + 0x63, 0x89, 0x12, 0x12, 0x59, 0x38, 0xe3, 0xcf, + 0xa0, 0xda, 0xbc, 0x69, 0x75, 0x48, 0x7c, 0x3e, + 0x56, 0x75, 0x12, 0x10, 0xc5, 0x96, 0x5b, 0x34, + 0x52, 0x2e, 0xce, 0xba, 0xd2, 0x7f, 0x8f, 0x1c, + 0xbd, 0x35, 0x3b, 0x74, 0x5b, 0x6c, 0xfe, 0xa7, + 0xf1, 0x4a, 0x07, 0x95, 0xff, 0xa8, 0xa0, 0x2a, + 0x85, 0xec, 0xd7, 0x56, 0x3b, 0x28, 0x2e, 0x09, + 0x50, 0x43, 0xbd, 0x49, 0x22, 0xdc, 0x78, 0x0e, + 0x7e, 0x68, 0x78, 0xd5, 0x57, 0xc2, 0xd6, 0x7c, + 0x2f, 0xd0, 0x4a, 0x62, 0x16, 0x38, 0x04, 0x23, + 0x43, 0x21, 0xaa, 0xe1, 0x96, 0x0e, 0xa9, 0x22, + 0xe7, 0x2c, 0xb8, 0x5e, 0x8f, 0xc6, 0x2d, 0xbd, + 0x99, 0x25, 0x33, 0xb8, 0x47, 0x99, 0x8d, 0xf5, + 0x22, 0x08, 0x9b, 0xd5, 0xad, 0x83, 0x67, 0xec, + 0x05, 0x89, 0xda, 0xd6, 0xe4, 0xe2, 0xd5, 0xef, + 0x7f, 0x61, 0x1e, 0x03, 0x81, 0x03, 0xb1, 0x98, + 0x5a, 0x29, 0x69, 0x13, 0xb2, 0xe6, 0xe1, 0x2c, + 0x66, 0x88, 0x39, 0x90, 0xf9, 0xae, 0x5d, 0x71, + 0xfe, 0x07, 0x30, 0x7d, 0xba, 0xa9, 0x37, 0xb5, + 0xff, 0x2c, 0xa9, 0xe6, 0x95, 0x48, 0xb2, 0xc8, +}; + +const struct testvec bf_cbc_448_1_vectors[] = { + { + .blkno = 0, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_448_encblkno1_vec0_ctxt, + }, + { + .blkno = 1, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_448_encblkno1_vec1_ctxt, + }, + { + .blkno = 2, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_448_encblkno1_vec2_ctxt, + }, + { + .blkno = 3, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_448_encblkno1_vec3_ctxt, + }, +}; + +/* + * IV method encblkno8, blkno 0. + */ +static const uint8_t bf_cbc_448_encblkno8_vec0_ctxt[SECSIZE] = { + 0x91, 0xb4, 0x8f, 0x78, 0x34, 0xbe, 0x03, 0xe9, + 0x4b, 0xca, 0xf4, 0xfa, 0x27, 0x99, 0xa0, 0xd0, + 0xa0, 0x85, 0xf9, 0xca, 0xcc, 0x2e, 0x0d, 0x41, + 0x91, 0xdb, 0xf9, 0x71, 0xcd, 0x49, 0xf7, 0x66, + 0x9b, 0x0c, 0x70, 0x49, 0x36, 0x72, 0xf4, 0xc0, + 0x17, 0xdd, 0xd8, 0x6a, 0xd2, 0x17, 0xfe, 0x50, + 0xa3, 0x2b, 0xa8, 0x7c, 0x9c, 0x12, 0x8c, 0x08, + 0x3d, 0xb5, 0x20, 0xc0, 0x83, 0xc1, 0xf5, 0x34, + 0x4b, 0xa5, 0xcc, 0x7c, 0xc6, 0x9f, 0x4b, 0x7f, + 0x09, 0x0c, 0x04, 0xe3, 0x02, 0xfe, 0xe2, 0x5a, + 0x45, 0xee, 0x4a, 0xcb, 0xc0, 0xe1, 0xf1, 0xae, + 0x1a, 0x22, 0x95, 0xb9, 0x30, 0xe8, 0x2d, 0x90, + 0xe5, 0x6a, 0x2f, 0x0a, 0x59, 0x15, 0xfc, 0x60, + 0xa5, 0x91, 0x95, 0x1a, 0xa2, 0xf5, 0x87, 0xa3, + 0x97, 0x45, 0x1b, 0xfb, 0x78, 0x62, 0x8b, 0xb6, + 0x86, 0xc6, 0x94, 0x9a, 0x9d, 0x09, 0x46, 0xc9, + 0x1f, 0x5f, 0x2e, 0x6c, 0xed, 0x5e, 0xe2, 0xab, + 0xca, 0x30, 0xdb, 0x13, 0x37, 0x8d, 0xb7, 0xc6, + 0xce, 0x74, 0xe3, 0xe2, 0x64, 0x7b, 0x74, 0x3e, + 0x9f, 0x18, 0x4e, 0xe2, 0x2b, 0x52, 0x08, 0x60, + 0x2b, 0x6d, 0x17, 0x1a, 0xff, 0xae, 0xfb, 0xea, + 0x59, 0x1d, 0x45, 0xe8, 0xf9, 0x0c, 0x56, 0xb8, + 0xb5, 0xc7, 0x8f, 0xa7, 0x9e, 0x67, 0x87, 0xbb, + 0xe2, 0x37, 0x56, 0x49, 0xed, 0x75, 0x27, 0x54, + 0xb5, 0x16, 0x34, 0xb6, 0xa6, 0xe0, 0x27, 0x48, + 0x91, 0xfb, 0x80, 0x4f, 0x5e, 0xef, 0x40, 0x6d, + 0x28, 0x8f, 0x2e, 0x56, 0xab, 0x6c, 0x7d, 0xde, + 0xbd, 0xa5, 0xa6, 0x47, 0xe2, 0xc9, 0xb0, 0xc5, + 0x69, 0x5d, 0x57, 0x18, 0x59, 0x08, 0x66, 0x1b, + 0xdc, 0x4f, 0xa4, 0xe2, 0xb5, 0xff, 0x72, 0x4d, + 0x25, 0x79, 0x38, 0x8f, 0xca, 0x23, 0x81, 0x31, + 0x1d, 0xeb, 0x7b, 0x7e, 0x04, 0xc3, 0xa6, 0xac, + 0x12, 0x92, 0x95, 0x44, 0x08, 0xae, 0x25, 0xb5, + 0xc2, 0x39, 0x88, 0x28, 0xc5, 0xc7, 0x3c, 0xfe, + 0x95, 0xe1, 0x1a, 0x27, 0xbe, 0xfd, 0x0a, 0xc7, + 0xd1, 0x02, 0x1a, 0xae, 0x03, 0xfb, 0xce, 0x79, + 0xe6, 0xea, 0x4a, 0xa1, 0x0e, 0x68, 0x61, 0x2f, + 0xfa, 0x7a, 0xb8, 0xda, 0xd1, 0x4a, 0xbe, 0x88, + 0xd2, 0xa0, 0x6b, 0x90, 0xc3, 0x37, 0x18, 0x77, + 0x2e, 0xc8, 0x44, 0x2e, 0x9d, 0xa2, 0x4a, 0xc7, + 0x54, 0xb2, 0x38, 0x9b, 0x60, 0x5e, 0x5b, 0xb0, + 0x31, 0x4c, 0x10, 0xf0, 0x1d, 0x8c, 0xab, 0x9b, + 0x25, 0x86, 0x05, 0xfc, 0xd9, 0x39, 0x11, 0x2b, + 0x7e, 0x07, 0xfd, 0x6b, 0xb3, 0x28, 0x57, 0x66, + 0x94, 0xc6, 0xfc, 0x48, 0x71, 0xeb, 0x7b, 0x9a, + 0x26, 0x8f, 0x9f, 0x97, 0xb6, 0x83, 0x9a, 0xdc, + 0x5d, 0x84, 0x96, 0x9d, 0xe3, 0xa5, 0x12, 0x97, + 0x8c, 0x87, 0xa6, 0x2a, 0xa8, 0x15, 0x9a, 0xb0, + 0x0e, 0x31, 0x55, 0xf7, 0x1b, 0x5c, 0x9c, 0xaf, + 0x13, 0x20, 0x13, 0x50, 0xaf, 0xc9, 0xf4, 0xd9, + 0x47, 0x16, 0xcc, 0x9d, 0xec, 0xa9, 0x2d, 0xfc, + 0x3d, 0x5d, 0x48, 0x89, 0x86, 0x91, 0x6f, 0x1a, + 0xa5, 0xf0, 0xb6, 0x9b, 0xa9, 0x08, 0xf2, 0x05, + 0xad, 0xe5, 0xe0, 0xd8, 0x2e, 0x09, 0xbe, 0x3a, + 0xf2, 0xdc, 0xeb, 0x14, 0xe6, 0x8c, 0x21, 0x20, + 0xbb, 0x42, 0x6a, 0xba, 0x55, 0x79, 0x54, 0x8b, + 0xa8, 0x43, 0x14, 0x28, 0x66, 0xd2, 0x44, 0x65, + 0x9c, 0xa9, 0xdc, 0x3b, 0x3f, 0xab, 0x36, 0xb4, + 0xbc, 0x9d, 0x22, 0x92, 0x24, 0xa8, 0x29, 0x18, + 0x98, 0x3a, 0xbe, 0xa1, 0xb4, 0xf8, 0x7f, 0xea, + 0x2f, 0x58, 0x69, 0xce, 0xee, 0x99, 0x76, 0x2c, + 0x53, 0x84, 0xf5, 0x9e, 0xa3, 0x98, 0xe6, 0x94, + 0x39, 0xfa, 0xfa, 0x6d, 0x66, 0xe2, 0x39, 0x2b, + 0x4b, 0x84, 0x14, 0x89, 0x18, 0xa2, 0x03, 0xdd, +}; + +/* + * IV method encblkno8, blkno 1. + */ +static const uint8_t bf_cbc_448_encblkno8_vec1_ctxt[SECSIZE] = { + 0x90, 0x3d, 0xee, 0x58, 0xf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0x3e, 0xa2, 0x48, 0xe7, 0x6c, 0x86, 0x65, 0x78, + 0x97, 0x0b, 0x97, 0xc1, 0x70, 0x91, 0x12, 0x79, + 0xae, 0xf0, 0x2b, 0x44, 0xe9, 0x84, 0x8d, 0x78, + 0x53, 0xf8, 0x3a, 0xf5, 0x9f, 0x27, 0x3d, 0x49, + 0x69, 0xd1, 0x18, 0xa4, 0xb2, 0xd0, 0xbb, 0xf2, + 0x57, 0x76, 0xb7, 0x77, 0x16, 0x2f, 0xf8, 0x0c, + 0xa5, 0x86, 0x43, 0x0d, 0x2d, 0xfe, 0x84, 0xc6, + 0xbb, 0x58, 0x81, 0x47, 0x3d, 0xa3, 0x93, 0xb0, + 0x50, 0xfc, 0x25, 0xf7, 0xc5, 0x05, 0xe5, 0xf2, + 0xb3, 0x79, 0x12, 0xe4, 0x37, 0x71, 0x2d, 0xe8, + 0xa5, 0x0b, 0xce, 0x67, 0x51, 0x4f, 0xab, 0xc7, + 0x7b, 0x3b, 0xac, 0x78, 0x97, 0x82, 0x02, 0xf4, + 0x62, 0x20, 0x1b, 0x8b, 0xac, 0x07, 0x3b, 0xd7, + 0x0b, 0x99, 0x27, 0x85, 0x52, 0x7a, 0x79, 0x18, + 0xfb, 0x81, 0x3a, 0x05, 0x76, 0x6c, 0x3c, 0x6a, + 0x35, 0xe1, 0x2b, 0x03, 0x48, 0x70, 0x1a, 0xa8, + 0x30, 0x33, 0x61, 0xe2, 0xd8, 0x99, 0x86, 0x7f, + 0xfd, 0xe0, 0x4a, 0xe4, 0x62, 0xa1, 0xac, 0xcb, + 0xb8, 0x8a, 0xf3, 0xaa, 0xd6, 0x61, 0x9d, 0xc5, + 0xdb, 0xf5, 0x53, 0x39, 0x1d, 0xd7, 0xf8, 0x96, + 0xc6, 0x2b, 0xca, 0xbf, 0x83, 0x4e, 0x89, 0x63, + 0x53, 0x6f, 0x17, 0xaa, 0xf3, 0x61, 0x9b, 0x75, + 0x8c, 0x5a, 0xf8, 0x21, 0x84, 0x52, 0xb8, 0x76, + 0xbc, 0xf5, 0x9b, 0xd6, 0x98, 0x26, 0x58, 0xec, + 0xdd, 0xa8, 0xf1, 0xee, 0x9e, 0x14, 0x24, 0x94, + 0x7c, 0xb6, 0x45, 0x8b, 0xc7, 0x85, 0x50, 0x4e, + 0x30, 0xd7, 0x51, 0x8c, 0x33, 0xeb, 0xeb, 0x5d, + 0x52, 0x58, 0x43, 0xcb, 0x25, 0x4a, 0x77, 0x34, + 0xe6, 0x70, 0x5b, 0x6f, 0x8f, 0xe8, 0x07, 0xee, + 0x76, 0x4a, 0xad, 0xab, 0x11, 0x8a, 0x1b, 0x92, + 0x60, 0x79, 0xb8, 0xe0, 0x88, 0xa7, 0x3a, 0xe0, + 0x15, 0xf6, 0x57, 0xf0, 0xe8, 0x87, 0xda, 0xf8, + 0x90, 0x4e, 0xe7, 0xb3, 0xb4, 0xe7, 0x73, 0x5c, + 0xd3, 0x69, 0xfb, 0x23, 0x4f, 0x4f, 0xc8, 0xd2, + 0xfb, 0xf5, 0xf5, 0x76, 0x80, 0xb6, 0xb7, 0xe2, + 0xb7, 0x96, 0x1a, 0x97, 0x12, 0x40, 0x16, 0x86, + 0xd6, 0x66, 0xf5, 0x46, 0x9e, 0x04, 0x62, 0xaa, + 0x9c, 0xc9, 0x45, 0x39, 0x5c, 0xd3, 0x58, 0x40, + 0xb4, 0x32, 0xd8, 0x6c, 0x19, 0xfa, 0xa5, 0x5f, + 0x1e, 0x83, 0x5a, 0x32, 0x5e, 0x1d, 0xab, 0xa9, + 0x48, 0x1b, 0x1b, 0x37, 0x66, 0xf8, 0x67, 0xd7, +}; + +/* + * IV method encblkno8, blkno 2. + */ +static const uint8_t bf_cbc_448_encblkno8_vec2_ctxt[SECSIZE] = { + 0xb3, 0x2d, 0x0d, 0x90, 0x7a, 0x50, 0xb6, 0x29, + 0x9d, 0xd4, 0x12, 0x1a, 0xc9, 0x71, 0x56, 0xc4, + 0xce, 0x3d, 0x74, 0xf9, 0x91, 0xe4, 0x79, 0x8a, + 0x42, 0x34, 0x1a, 0xd4, 0x84, 0xaa, 0x01, 0x85, + 0x13, 0xe8, 0xab, 0xaa, 0xb6, 0x81, 0x82, 0xd6, + 0x32, 0xd6, 0x9f, 0x63, 0x69, 0x55, 0x10, 0x5f, + 0x2e, 0xb3, 0x51, 0x74, 0x80, 0x5c, 0xe9, 0x8d, + 0x27, 0xd8, 0x41, 0x2d, 0x27, 0x07, 0xb4, 0x13, + 0xcd, 0xc0, 0xb3, 0x96, 0xaa, 0x59, 0x9c, 0x3e, + 0x16, 0x9e, 0x18, 0xa5, 0x92, 0x52, 0x59, 0x19, + 0x19, 0x62, 0xeb, 0xd9, 0xdf, 0x9d, 0x10, 0x77, + 0xfb, 0x3c, 0xf1, 0xeb, 0x70, 0xf6, 0x6a, 0x9b, + 0xad, 0x99, 0x35, 0xd7, 0xf8, 0xde, 0x2b, 0x52, + 0x85, 0xdd, 0x36, 0x07, 0x3a, 0x88, 0xa6, 0xbb, + 0x98, 0x7a, 0xe3, 0xb0, 0xe6, 0xae, 0x33, 0x5d, + 0x47, 0x0c, 0x6c, 0xd4, 0x84, 0x33, 0x7e, 0xf4, + 0xea, 0xfd, 0xf1, 0x1c, 0xdb, 0x8b, 0xfe, 0x01, + 0x77, 0xa3, 0x07, 0x21, 0x09, 0xac, 0x0c, 0xe4, + 0x63, 0xaa, 0x3d, 0xb3, 0x05, 0xf8, 0x73, 0x03, + 0x69, 0x53, 0x2f, 0xd3, 0x53, 0x29, 0xf2, 0x02, + 0x60, 0x41, 0xed, 0xc7, 0xe9, 0x2e, 0xba, 0x54, + 0xa4, 0xfe, 0x26, 0xf0, 0xd9, 0x2c, 0x58, 0x2d, + 0x90, 0x94, 0x19, 0xf9, 0xe5, 0xaa, 0xe2, 0x13, + 0x9a, 0x67, 0x90, 0x44, 0x61, 0x36, 0xd0, 0x3f, + 0xe7, 0xe8, 0x7e, 0x47, 0x2b, 0x84, 0x97, 0xe2, + 0x0b, 0x8a, 0xfa, 0x2f, 0xbc, 0x1a, 0x70, 0xed, + 0xb2, 0x93, 0x36, 0x0e, 0xe6, 0xb1, 0xa2, 0x5a, + 0x04, 0x04, 0x8d, 0x2f, 0x82, 0xdb, 0x49, 0x5e, + 0x1b, 0x90, 0xc1, 0x27, 0x2a, 0x2f, 0x64, 0x5b, + 0xce, 0x35, 0x06, 0x0d, 0xb6, 0x05, 0x50, 0x5a, + 0x90, 0xc8, 0x21, 0xd0, 0xf0, 0xb9, 0xf3, 0x43, + 0x25, 0xd8, 0xb9, 0x86, 0xb7, 0xd0, 0x29, 0x75, + 0xdc, 0xf6, 0xf6, 0x14, 0x5e, 0x1f, 0xad, 0x54, + 0x28, 0x63, 0x92, 0xcd, 0xcd, 0x75, 0xb2, 0xe8, + 0xf3, 0x1f, 0xfd, 0x88, 0x72, 0x04, 0xab, 0xe2, + 0x77, 0x21, 0xc1, 0xb4, 0x87, 0xa7, 0x98, 0x86, + 0x2d, 0x7f, 0x01, 0x24, 0xed, 0x3a, 0x23, 0x83, + 0xb7, 0xa4, 0xb7, 0x08, 0x4e, 0xee, 0x10, 0x77, + 0x29, 0x22, 0xab, 0xea, 0x4a, 0x68, 0x1f, 0x7f, + 0xd6, 0xe6, 0x90, 0x11, 0xbc, 0x23, 0x2e, 0x47, + 0x78, 0xea, 0x1d, 0x33, 0x7c, 0x02, 0x09, 0x55, + 0x7a, 0xbc, 0xa7, 0x3d, 0x9a, 0xd0, 0x4d, 0x40, + 0x6c, 0xc2, 0x99, 0xc2, 0xe9, 0x0e, 0xcf, 0x06, + 0x82, 0x61, 0x5c, 0x76, 0xca, 0xef, 0x8f, 0xd3, + 0x78, 0x2a, 0xae, 0x39, 0x29, 0x4e, 0xc1, 0x2c, + 0xb1, 0xbc, 0xcd, 0x76, 0x4f, 0x25, 0xf0, 0x5b, + 0x78, 0x3a, 0xa4, 0x39, 0x52, 0x5a, 0xc7, 0xcf, + 0x17, 0x3d, 0xb0, 0x39, 0x63, 0xf9, 0xf9, 0xfb, + 0x6f, 0x35, 0xb7, 0xf1, 0x49, 0x10, 0xd8, 0x12, + 0x8d, 0xa2, 0xdf, 0xc5, 0x26, 0x37, 0xd1, 0xb8, + 0xef, 0xdc, 0x04, 0x1b, 0x0d, 0x60, 0xbf, 0xbc, + 0xc0, 0xff, 0x56, 0x8b, 0xd3, 0x6e, 0x71, 0xfc, + 0x87, 0x00, 0x86, 0x10, 0x78, 0x3b, 0xce, 0x8b, + 0xe8, 0x5f, 0x8c, 0xce, 0x03, 0xa2, 0x89, 0x8c, + 0x16, 0x00, 0x0e, 0xd8, 0x53, 0xaf, 0x7f, 0x77, + 0x78, 0x40, 0x5e, 0x5e, 0xd1, 0x7d, 0xf8, 0x41, + 0xa8, 0x1e, 0xa5, 0xe5, 0xe9, 0xd6, 0x17, 0x2c, + 0x2f, 0x1b, 0xff, 0xef, 0xf5, 0x53, 0x31, 0xf3, + 0x5b, 0xe4, 0x84, 0x7c, 0xe2, 0x45, 0x3c, 0x82, + 0x5b, 0xf6, 0x03, 0x35, 0xdd, 0x03, 0x22, 0xbe, + 0x77, 0x9c, 0x6a, 0x7d, 0xc8, 0x29, 0x41, 0x53, + 0xbb, 0xab, 0x6e, 0xa5, 0x00, 0xaf, 0x3b, 0x1d, + 0x76, 0x12, 0xac, 0x44, 0x5c, 0x7d, 0xd2, 0x3b, + 0x3a, 0x95, 0xb0, 0xa9, 0x4f, 0x27, 0x76, 0x17, +}; + +/* + * IV method encblkno8, blkno 3. + */ +static const uint8_t bf_cbc_448_encblkno8_vec3_ctxt[SECSIZE] = { + 0x8e, 0xc4, 0x56, 0x64, 0x1e, 0x2a, 0x0d, 0x60, + 0x54, 0x5c, 0xcd, 0xe0, 0x6d, 0xa7, 0x4c, 0x30, + 0x7e, 0x85, 0x21, 0xdf, 0xaa, 0xb2, 0x32, 0xde, + 0xc0, 0xc6, 0x56, 0xe0, 0x43, 0xc2, 0x3e, 0x6c, + 0x8c, 0x62, 0x35, 0xaa, 0xf9, 0xba, 0xc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 0x76, 0xb4, + 0xd7, 0xc3, 0x1b, 0x65, 0x99, 0xc6, 0xa3, 0xe8, + 0x96, 0x5e, 0xc1, 0x0c, 0xd2, 0xf8, 0x65, 0xcf, + 0x42, 0xc5, 0x8f, 0x52, 0x5d, 0x90, 0x21, 0x55, + 0xec, 0x9d, 0x93, 0x81, 0xb7, 0x9a, 0xa4, 0x35, + 0xe7, 0xef, 0xef, 0x2d, 0x4c, 0x02, 0xf7, 0x2b, + 0x26, 0xe0, 0x9e, 0x3a, 0x31, 0xfd, 0x94, 0xb3, + 0xa7, 0x8a, 0x93, 0xf3, 0xe1, 0x77, 0x79, 0xdf, + 0xcf, 0x1f, 0x99, 0x55, 0x20, 0xc3, 0x7d, 0x8a, + 0xbc, 0xff, 0x63, 0x64, 0x87, 0xa9, 0x42, 0x63, + 0xc9, 0x67, 0x7e, 0x51, 0x99, 0x9c, 0xcb, 0x47, + 0xa9, 0xc8, 0x5e, 0x83, 0x87, 0x55, 0x7c, 0x45, + 0x3a, 0xb4, 0xfe, 0x97, 0x24, 0x17, 0x1d, 0x5e, + 0xdf, 0xe0, 0xe8, 0x17, 0xa6, 0x31, 0x99, 0xeb, + 0xb7, 0xb5, 0xd5, 0xd7, 0x7c, 0x2f, 0x22, 0x26, +}; + +const struct testvec bf_cbc_448_8_vectors[] = { + { + .blkno = 0, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_448_encblkno8_vec0_ctxt, + }, + { + .blkno = 1, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_448_encblkno8_vec1_ctxt, + }, + { + .blkno = 2, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_448_encblkno8_vec2_ctxt, + }, + { + .blkno = 3, + .ptxt = bf_cbc_ptxt, + .ctxt = bf_cbc_448_encblkno8_vec3_ctxt, + }, +}; + +static int +open_disk(const char *devpath, const char *imgpath, size_t size) +{ + int fd; + + fd = open(imgpath, O_CREAT | O_RDWR | O_TRUNC, 0600); + if (fd < 0) + return -1; + + if (ftruncate(fd, size) < 0) + goto fail; + + if (rump_pub_etfs_register_withsize(devpath, + imgpath, RUMP_ETFS_BLK, 0, size) < 0) { + goto fail; + } + + unlink(imgpath); + return fd; +fail: + close(fd); + unlink(imgpath); + return -1; +} + +static int +open_cgd(int devno) +{ + char devpath[32]; + + sprintf(devpath, "/dev/rcgd%d%c", devno, getrawpartition() + 'a'); + + return rump_sys_open(devpath, O_RDWR, 0); +} + +static int +configure_cgd(int fd, const char *dkpath, const char *alg, + const char *ivmethod, const char *key, size_t keylen) +{ + struct cgd_ioctl ci; + + memset(&ci, 0, sizeof(ci)); + ci.ci_disk = dkpath; + ci.ci_alg = alg; + ci.ci_ivmethod = ivmethod; + ci.ci_keylen = 8 * keylen - 8; /* Exclude the NUL terminator. */ + ci.ci_key = key; + ci.ci_blocksize = 64; + + return rump_sys_ioctl(fd, CGDIOCSET, &ci); +} + +static int +unconfigure_cgd(int fd) +{ + struct cgd_ioctl ci; + + return rump_sys_ioctl(fd, CGDIOCCLR, &ci); +} + +static int +write_testvec(int cgdfd, const struct testvec *tv) +{ + + if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0) + return -1; + + if (rump_sys_write(cgdfd, tv->ptxt, SECSIZE) != SECSIZE) + return -1; + + return 0; +} + +static int +read_testvec(int cgdfd, const struct testvec *tv) +{ + char *buf; + int res = -1; + + buf = malloc(SECSIZE); + if (buf == NULL) + return -1; + + if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0) + goto fail; + + if (rump_sys_read(cgdfd, buf, SECSIZE) != SECSIZE) + goto fail; + + res = memcmp(buf, tv->ptxt, SECSIZE); +fail: + free(buf); + return res; +} + +static int +check_testvec(int dkfd, const struct testvec *tv) +{ + char *buf; + int res = -1; + + buf = malloc(SECSIZE); + if (buf == NULL) + return -1; + + if (lseek(dkfd, tv->blkno * SECSIZE, SEEK_SET) < 0) + goto fail; + + if (read(dkfd, buf, SECSIZE) != SECSIZE) + goto fail; + + res = memcmp(buf, tv->ctxt, SECSIZE); +fail: + free(buf); + return res; +} + +ATF_TC(cgd_bf_cbc_128_encblkno1); +ATF_TC_HEAD(cgd_bf_cbc_128_encblkno1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test blowfish-cbc with 128 bits key, ivmethod encblkno1"); +} + +ATF_TC_BODY(cgd_bf_cbc_128_encblkno1, tc) +{ + const char imgpath[] = "blowfish-cbc-128-encblkno1.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1", + bf_cbc_128_key, sizeof(bf_cbc_128_key))); + + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_1_vectors[0]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_1_vectors[1]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_1_vectors[2]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_1_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1", + bf_cbc_128_key, sizeof(bf_cbc_128_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_1_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_1_vectors[1]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_1_vectors[2]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_1_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_1_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_1_vectors[1]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_1_vectors[2]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_1_vectors[3]), 0); + + RL(close(dkfd)); +} + +ATF_TC(cgd_bf_cbc_128_encblkno8); +ATF_TC_HEAD(cgd_bf_cbc_128_encblkno8, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test blowfish-cbc with 128 bits key, ivmethod encblkno8"); +} + +ATF_TC_BODY(cgd_bf_cbc_128_encblkno8, tc) +{ + const char imgpath[] = "blowfish-cbc-128-encblkno8.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8", + bf_cbc_128_key, sizeof(bf_cbc_128_key))); + + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_8_vectors[0]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_8_vectors[1]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_8_vectors[2]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_8_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8", + bf_cbc_128_key, sizeof(bf_cbc_128_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_8_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_8_vectors[1]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_8_vectors[2]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_8_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_8_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_8_vectors[1]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_8_vectors[2]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_8_vectors[3]), 0); + + RL(close(dkfd)); +} + +ATF_TC(cgd_bf_cbc_256_encblkno1); +ATF_TC_HEAD(cgd_bf_cbc_256_encblkno1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test blowfish-cbc with 256 bits key, ivmethod encblkno1"); +} + +ATF_TC_BODY(cgd_bf_cbc_256_encblkno1, tc) +{ + const char imgpath[] = "blowfish-cbc-256-encblkno1.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1", + bf_cbc_256_key, sizeof(bf_cbc_256_key))); + + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_1_vectors[0]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_1_vectors[1]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_1_vectors[2]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_1_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1", + bf_cbc_256_key, sizeof(bf_cbc_256_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_1_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_1_vectors[1]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_1_vectors[2]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_1_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_1_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_1_vectors[1]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_1_vectors[2]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_1_vectors[3]), 0); + + RL(close(dkfd)); +} + +ATF_TC(cgd_bf_cbc_256_encblkno8); +ATF_TC_HEAD(cgd_bf_cbc_256_encblkno8, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test blowfish-cbc with 256 bits key, ivmethod encblkno8"); +} + +ATF_TC_BODY(cgd_bf_cbc_256_encblkno8, tc) +{ + const char imgpath[] = "blowfish-cbc-256-encblkno8.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8", + bf_cbc_256_key, sizeof(bf_cbc_256_key))); + + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_8_vectors[0]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_8_vectors[1]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_8_vectors[2]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_8_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8", + bf_cbc_256_key, sizeof(bf_cbc_256_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_8_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_8_vectors[1]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_8_vectors[2]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_8_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_8_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_8_vectors[1]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_8_vectors[2]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_8_vectors[3]), 0); + + RL(close(dkfd)); +} + +ATF_TC(cgd_bf_cbc_448_encblkno1); +ATF_TC_HEAD(cgd_bf_cbc_448_encblkno1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test blowfish-cbc with 448 bits key, ivmethod encblkno1"); +} + +ATF_TC_BODY(cgd_bf_cbc_448_encblkno1, tc) +{ + const char imgpath[] = "blowfish-cbc-448-encblkno1.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1", + bf_cbc_448_key, sizeof(bf_cbc_448_key))); + + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_1_vectors[0]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_1_vectors[1]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_1_vectors[2]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_1_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1", + bf_cbc_448_key, sizeof(bf_cbc_448_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_1_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_1_vectors[1]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_1_vectors[2]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_1_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_1_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_1_vectors[1]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_1_vectors[2]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_1_vectors[3]), 0); + + RL(close(dkfd)); +} + +ATF_TC(cgd_bf_cbc_448_encblkno8); +ATF_TC_HEAD(cgd_bf_cbc_448_encblkno8, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test blowfish-cbc with 448 bits key, ivmethod encblkno8"); +} + +ATF_TC_BODY(cgd_bf_cbc_448_encblkno8, tc) +{ + const char imgpath[] = "blowfish-cbc-448-encblkno8.img"; + const char *dkpath = "/dev/dk"; + const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */ + int dkfd, cgdfd; + + rump_init(); + + RL(dkfd = open_disk(dkpath, imgpath, dksize)); + + RL(cgdfd = open_cgd(0)); + RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8", + bf_cbc_448_key, sizeof(bf_cbc_448_key))); + + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_8_vectors[0]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_8_vectors[1]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_8_vectors[2]), 0); + ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_8_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8", + bf_cbc_448_key, sizeof(bf_cbc_448_key))); + + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_8_vectors[0]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_8_vectors[1]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_8_vectors[2]), 0); + ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_8_vectors[3]), 0); + + RL(unconfigure_cgd(cgdfd)); + RL(rump_sys_close(cgdfd)); + + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_8_vectors[0]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_8_vectors[1]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_8_vectors[2]), 0); + ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_8_vectors[3]), 0); + + RL(close(dkfd)); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, cgd_bf_cbc_128_encblkno1); + ATF_TP_ADD_TC(tp, cgd_bf_cbc_128_encblkno8); + ATF_TP_ADD_TC(tp, cgd_bf_cbc_256_encblkno1); + ATF_TP_ADD_TC(tp, cgd_bf_cbc_256_encblkno8); + ATF_TP_ADD_TC(tp, cgd_bf_cbc_448_encblkno1); + ATF_TP_ADD_TC(tp, cgd_bf_cbc_448_encblkno8); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/fs/ffs/ffs_common.sh b/contrib/netbsd-tests/fs/ffs/ffs_common.sh index eaf7142..ee94a15 100755 --- a/contrib/netbsd-tests/fs/ffs/ffs_common.sh +++ b/contrib/netbsd-tests/fs/ffs/ffs_common.sh @@ -1,4 +1,4 @@ -# $NetBSD: ffs_common.sh,v 1.2 2013/07/29 13:15:24 skrll Exp $ +# $NetBSD: ffs_common.sh,v 1.3 2016/10/08 13:23:53 gson Exp $ create_ffs() { @@ -45,7 +45,7 @@ test_case() eval "${name}_head() { \ atf_set "descr" "${descr}" - atf_set "timeout" "60" + atf_set "timeout" "120" }" eval "${name}_body() { \ RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \ diff --git a/contrib/netbsd-tests/fs/fifofs/t_fifo.c b/contrib/netbsd-tests/fs/fifofs/t_fifo.c index c4a2060..4b37bb8 100644 --- a/contrib/netbsd-tests/fs/fifofs/t_fifo.c +++ b/contrib/netbsd-tests/fs/fifofs/t_fifo.c @@ -1,9 +1,10 @@ /* Test case written by Bharat Joshi */ #include -__RCSID("$NetBSD: t_fifo.c,v 1.1 2011/12/21 00:17:07 christos Exp $"); +__RCSID("$NetBSD: t_fifo.c,v 1.2 2017/01/10 22:36:29 christos Exp $"); #include #include +#include #include #include diff --git a/contrib/netbsd-tests/fs/psshfs/t_psshfs.sh b/contrib/netbsd-tests/fs/psshfs/t_psshfs.sh index 241d46d..4d8fede 100755 --- a/contrib/netbsd-tests/fs/psshfs/t_psshfs.sh +++ b/contrib/netbsd-tests/fs/psshfs/t_psshfs.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_psshfs.sh,v 1.7 2013/03/16 07:54:04 jmmv Exp $ +# $NetBSD: t_psshfs.sh,v 1.8 2016/09/05 08:53:57 christos Exp $ # # Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. # All rights reserved. @@ -262,6 +262,26 @@ setattr_cache_cleanup() { stop_ssh } +atf_test_case read_empty_file cleanup +read_empty_file_head() { + atf_set "descr" "Checks whether an empty file can be read" + # This test is supposed to make sure psshfs does not hang + # when reading from an empty file, hence the timeout. + atf_set "timeout" 8 +} +read_empty_file_body() { + require_puffs + start_ssh + atf_check mkdir root mnt + atf_check -x ': > root/empty' + mount_psshfs root mnt + atf_check cat mnt/empty +} +read_empty_file_cleanup() { + umount mnt + stop_ssh +} + # ------------------------------------------------------------------------- # Initialization. # ------------------------------------------------------------------------- @@ -271,4 +291,5 @@ atf_init_test_cases() { atf_add_test_case pwd atf_add_test_case ls #atf_add_test_case setattr_cache + atf_add_test_case read_empty_file } diff --git a/contrib/netbsd-tests/fs/puffs/t_basic.c b/contrib/netbsd-tests/fs/puffs/t_basic.c index ce5e4ea..735108d 100644 --- a/contrib/netbsd-tests/fs/puffs/t_basic.c +++ b/contrib/netbsd-tests/fs/puffs/t_basic.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_basic.c,v 1.12 2013/10/19 17:45:00 christos Exp $ */ +/* $NetBSD: t_basic.c,v 1.13 2016/12/01 14:49:04 hannken Exp $ */ #include #include @@ -286,7 +286,7 @@ ATF_TC_BODY(inactive_reclaim, tc) rump_sys_close(fd); syncbar(FSTEST_MNTNAME); - ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE], 1); + ATF_REQUIRE(pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE] > 0); ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_RECLAIM], 1); FSTEST_EXIT(); @@ -383,7 +383,7 @@ ATF_TC_BODY(unlink_accessible, tc) syncbar(FSTEST_MNTNAME); ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_RECLAIM], 1); - ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE], ianow+1); + ATF_REQUIRE(pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE] > ianow); ATF_REQUIRE_STREQ(buf, MAGICSTR); diff --git a/contrib/netbsd-tests/fs/vfs/t_vnops.c b/contrib/netbsd-tests/fs/vfs/t_vnops.c index 08203dd..978fadb 100644 --- a/contrib/netbsd-tests/fs/vfs/t_vnops.c +++ b/contrib/netbsd-tests/fs/vfs/t_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_vnops.c,v 1.55 2016/01/28 10:10:09 martin Exp $ */ +/* $NetBSD: t_vnops.c,v 1.58 2016/08/29 02:31:46 kre Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -55,10 +56,10 @@ atf_tc_skip("symlinks not supported by file system") static char * -md(char *buf, const char *base, const char *tail) +md(char *buf, size_t buflen, const char *base, const char *tail) { - sprintf(buf, "%s/%s", base, tail); + snprintf(buf, buflen, "%s/%s", base, tail); return buf; } @@ -69,11 +70,11 @@ lookup_simple(const atf_tc_t *tc, const char *mountpath) struct stat sb1, sb2; strcpy(final, mountpath); - sprintf(pb, "%s/../%s", mountpath, basename(final)); + snprintf(pb, sizeof(pb), "%s/../%s", mountpath, basename(final)); if (rump_sys_stat(pb, &sb1) == -1) atf_tc_fail_errno("stat 1"); - sprintf(pb, "%s/./../%s", mountpath, basename(final)); + snprintf(pb, sizeof(pb), "%s/./../%s", mountpath, basename(final)); if (rump_sys_stat(pb, &sb2) == -1) atf_tc_fail_errno("stat 2"); @@ -85,22 +86,38 @@ lookup_complex(const atf_tc_t *tc, const char *mountpath) { char pb[MAXPATHLEN]; struct stat sb1, sb2; + struct timespec atplus1, onesec; USES_DIRS; - if (FSTYPE_UDF(tc)) - atf_tc_expect_fail("PR kern/49033"); - - sprintf(pb, "%s/dir", mountpath); + snprintf(pb, sizeof(pb), "%s/dir", mountpath); if (rump_sys_mkdir(pb, 0777) == -1) atf_tc_fail_errno("mkdir"); if (rump_sys_stat(pb, &sb1) == -1) atf_tc_fail_errno("stat 1"); - sprintf(pb, "%s/./dir/../././dir/.", mountpath); + snprintf(pb, sizeof(pb), "%s/./dir/../././dir/.", mountpath); if (rump_sys_stat(pb, &sb2) == -1) atf_tc_fail_errno("stat 2"); + /* + * The lookup is permitted to modify the access time of + * any directories searched - such a directory is the + * subject of this test. Any difference should cause + * the 2nd lookup atime tp be >= the first, if it is ==, all is + * OK (atime is not required to be modified by the search, or + * both references may happen within the came clock tick), if the + * 2nd lookup atime is > the first, but not "too much" greater, + * just set it back, so the memcmp just below succeeds + * (assuming all else is OK). + */ + onesec.tv_sec = 1; + onesec.tv_nsec = 0; + timespecadd(&sb1.st_atimespec, &onesec, &atplus1); + if (timespeccmp(&sb2.st_atimespec, &sb1.st_atimespec, >) && + timespeccmp(&sb2.st_atimespec, &atplus1, <)) + sb2.st_atimespec = sb1.st_atimespec; + if (memcmp(&sb1, &sb2, sizeof(sb1)) != 0) { printf("what\tsb1\t\tsb2\n"); @@ -133,9 +150,6 @@ lookup_complex(const atf_tc_t *tc, const char *mountpath) atf_tc_fail("stat results differ, see ouput for more details"); } - if (FSTYPE_UDF(tc)) - atf_tc_fail("random failure of PR kern/49033 " - "did not happen this time"); } static void @@ -147,7 +161,7 @@ dir_simple(const atf_tc_t *tc, const char *mountpath) USES_DIRS; /* check we can create directories */ - sprintf(pb, "%s/dir", mountpath); + snprintf(pb, sizeof(pb), "%s/dir", mountpath); if (rump_sys_mkdir(pb, 0777) == -1) atf_tc_fail_errno("mkdir"); if (rump_sys_stat(pb, &sb) == -1) @@ -169,11 +183,11 @@ dir_notempty(const atf_tc_t *tc, const char *mountpath) USES_DIRS; /* check we can create directories */ - sprintf(pb, "%s/dir", mountpath); + snprintf(pb, sizeof(pb), "%s/dir", mountpath); if (rump_sys_mkdir(pb, 0777) == -1) atf_tc_fail_errno("mkdir"); - sprintf(pb2, "%s/dir/file", mountpath); + snprintf(pb2, sizeof(pb2), "%s/dir/file", mountpath); fd = rump_sys_open(pb2, O_RDWR | O_CREAT, 0777); if (fd == -1) atf_tc_fail_errno("create file"); @@ -205,9 +219,9 @@ dir_rmdirdotdot(const atf_tc_t *tc, const char *mp) RL(rump_sys_mkdir("subtest", 0777)); RL(rump_sys_chdir("subtest")); - md(pb, mp, "test/subtest"); + md(pb, sizeof(pb), mp, "test/subtest"); RL(rump_sys_rmdir(pb)); - md(pb, mp, "test"); + md(pb, sizeof(pb), mp, "test"); RL(rump_sys_rmdir(pb)); if (FSTYPE_NFS(tc)) @@ -225,7 +239,7 @@ checkfile(const char *path, struct stat *refp) struct stat sb; static int n = 1; - md(buf, path, "file"); + md(buf, sizeof(buf), path, "file"); if (rump_sys_stat(buf, &sb) == -1) atf_tc_fail_errno("cannot stat file %d (%s)", n, buf); if (memcmp(&sb, refp, sizeof(sb)) != 0) @@ -244,18 +258,18 @@ rename_dir(const atf_tc_t *tc, const char *mp) USES_DIRS; - md(pb1, mp, "dir1"); + md(pb1, sizeof(pb1), mp, "dir1"); if (rump_sys_mkdir(pb1, 0777) == -1) atf_tc_fail_errno("mkdir 1"); - md(pb2, mp, "dir2"); + md(pb2, sizeof(pb2), mp, "dir2"); if (rump_sys_mkdir(pb2, 0777) == -1) atf_tc_fail_errno("mkdir 2"); - md(pb2, mp, "dir2/subdir"); + md(pb2, sizeof(pb2), mp, "dir2/subdir"); if (rump_sys_mkdir(pb2, 0777) == -1) atf_tc_fail_errno("mkdir 3"); - md(pb3, mp, "dir1/file"); + md(pb3, sizeof(pb3), mp, "dir1/file"); if (rump_sys_mknod(pb3, S_IFREG | 0777, -1) == -1) atf_tc_fail_errno("create file"); if (rump_sys_stat(pb3, &ref) == -1) @@ -266,13 +280,13 @@ rename_dir(const atf_tc_t *tc, const char *mp) */ /* rename within directory */ - md(pb3, mp, "dir3"); + md(pb3, sizeof(pb3), mp, "dir3"); if (rump_sys_rename(pb1, pb3) == -1) atf_tc_fail_errno("rename 1"); checkfile(pb3, &ref); /* rename directory onto itself (two ways, should fail) */ - md(pb1, mp, "dir3/."); + md(pb1, sizeof(pb1), mp, "dir3/."); if (rump_sys_rename(pb1, pb3) != -1 || errno != EINVAL) atf_tc_fail_errno("rename 2"); if (rump_sys_rename(pb3, pb1) != -1 || errno != EISDIR) @@ -281,13 +295,13 @@ rename_dir(const atf_tc_t *tc, const char *mp) checkfile(pb3, &ref); /* rename father of directory into directory */ - md(pb1, mp, "dir2/dir"); - md(pb2, mp, "dir2"); + md(pb1, sizeof(pb1), mp, "dir2/dir"); + md(pb2, sizeof(pb2), mp, "dir2"); if (rump_sys_rename(pb2, pb1) != -1 || errno != EINVAL) atf_tc_fail_errno("rename 4"); /* same for grandfather */ - md(pb1, mp, "dir2/subdir/dir2"); + md(pb1, sizeof(pb1), mp, "dir2/subdir/dir2"); if (rump_sys_rename(pb2, pb1) != -1 || errno != EINVAL) atf_tc_fail("rename 5"); @@ -298,29 +312,29 @@ rename_dir(const atf_tc_t *tc, const char *mp) atf_tc_fail("rename 6"); /* cross-directory rename */ - md(pb1, mp, "dir3"); - md(pb2, mp, "dir2/somedir"); + md(pb1, sizeof(pb1), mp, "dir3"); + md(pb2, sizeof(pb2), mp, "dir2/somedir"); if (rump_sys_rename(pb1, pb2) == -1) atf_tc_fail_errno("rename 7"); checkfile(pb2, &ref); /* move to parent directory */ - md(pb1, mp, "dir2/somedir/../../dir3"); + md(pb1, sizeof(pb1), mp, "dir2/somedir/../../dir3"); if (rump_sys_rename(pb2, pb1) == -1) atf_tc_fail_errno("rename 8"); - md(pb1, mp, "dir2/../dir3"); + md(pb1, sizeof(pb1), mp, "dir2/../dir3"); checkfile(pb1, &ref); /* atomic cross-directory rename */ - md(pb3, mp, "dir2/subdir"); + md(pb3, sizeof(pb3), mp, "dir2/subdir"); if (rump_sys_rename(pb1, pb3) == -1) atf_tc_fail_errno("rename 9"); checkfile(pb3, &ref); /* rename directory over an empty directory */ - md(pb1, mp, "parent"); - md(pb2, mp, "parent/dir1"); - md(pb3, mp, "parent/dir2"); + md(pb1, sizeof(pb1), mp, "parent"); + md(pb2, sizeof(pb2), mp, "parent/dir1"); + md(pb3, sizeof(pb3), mp, "parent/dir2"); RL(rump_sys_mkdir(pb1, 0777)); RL(rump_sys_mkdir(pb2, 0777)); RL(rump_sys_mkdir(pb3, 0777)); @@ -467,15 +481,15 @@ create_many(const atf_tc_t *tc, const char *mp) for (i = 0; i < nfiles; i++) { int fd; - sprintf(buf, TESTFN "%d", i); + snprintf(buf, sizeof(buf), TESTFN "%d", i); RL(fd = rump_sys_open(buf, O_RDWR|O_CREAT|O_EXCL, 0666)); RL(rump_sys_close(fd)); } /* wipe them out */ for (i = 0; i < nfiles; i++) { - sprintf(buf, TESTFN "%d", i); - RL(rump_sys_unlink(buf)); + snprintf(buf, sizeof(buf), TESTFN "%d", i); + RLF(rump_sys_unlink(buf), "%s", buf); } #undef TESTFN @@ -499,12 +513,12 @@ create_nonalphanum(const atf_tc_t *tc, const char *mp) for (i = 0; i < 256; i++) { int fd; - sprintf(buf, "%c", i); + snprintf(buf, sizeof(buf), "%c", i); fd = rump_sys_open(buf, O_RDWR|O_CREAT|O_EXCL, 0666); if (fd == -1) continue; - RL(rump_sys_close(fd)); - RL(rump_sys_unlink(buf)); + RLF(rump_sys_close(fd), "%d", fd); + RLF(rump_sys_unlink(buf), "%s", buf); } printf("\n"); @@ -632,7 +646,7 @@ symlink_len(const atf_tc_t *tc, const char *mp, size_t len) USES_SYMLINKS; - RL(rump_sys_chdir(mp)); + RLF(rump_sys_chdir(mp), "%s", mp); buf = malloc(len + 1); ATF_REQUIRE(buf); diff --git a/contrib/netbsd-tests/h_macros.h b/contrib/netbsd-tests/h_macros.h index 29b4e99..dd730c9 100644 --- a/contrib/netbsd-tests/h_macros.h +++ b/contrib/netbsd-tests/h_macros.h @@ -1,4 +1,4 @@ -/* $NetBSD: h_macros.h,v 1.12 2016/08/04 11:49:07 jakllsch Exp $ */ +/* $NetBSD: h_macros.h,v 1.13 2016/08/20 15:49:08 christos Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -45,6 +45,8 @@ ATF_CHECK_MSG((x) != (v), "%s: %s", #x, strerror(errno)) #define RL(x) REQUIRE_LIBC(x, -1) +#define RLF(x, fmt, arg) \ + ATF_CHECK_MSG((x) != -1, "%s [" fmt "]: %s", #x, arg, strerror(errno)) #define RZ(x) \ do { \ int RZ_rv = x; \ diff --git a/contrib/netbsd-tests/kernel/msg.h b/contrib/netbsd-tests/kernel/msg.h new file mode 100644 index 0000000..547400e --- /dev/null +++ b/contrib/netbsd-tests/kernel/msg.h @@ -0,0 +1,136 @@ +/* $NetBSD: msg.h,v 1.1 2016/12/05 20:10:10 christos Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +struct msg_fds { + int pfd[2]; + int cfd[2]; +}; + +#define CLOSEFD(fd) do { \ + if (fd != -1) { \ + close(fd); \ + fd = -1; \ + } \ +} while (/*CONSTCOND*/ 0) + +static int +msg_open(struct msg_fds *fds) +{ + if (pipe(fds->pfd) == -1) + return -1; + if (pipe(fds->cfd) == -1) { + close(fds->pfd[0]); + close(fds->pfd[1]); + return -1; + } + return 0; +} + +static void +msg_close(struct msg_fds *fds) +{ + CLOSEFD(fds->pfd[0]); + CLOSEFD(fds->pfd[1]); + CLOSEFD(fds->cfd[0]); + CLOSEFD(fds->cfd[1]); +} + +static int +msg_write_child(const char *info, struct msg_fds *fds, void *msg, size_t len) +{ + ssize_t rv; + CLOSEFD(fds->cfd[1]); + CLOSEFD(fds->pfd[0]); + + printf("Send %s\n", info); + rv = write(fds->pfd[1], msg, len); + if (rv != (ssize_t)len) + return 1; +// printf("Wait %s\n", info); + rv = read(fds->cfd[0], msg, len); + if (rv != (ssize_t)len) + return 1; + return 0; +} + +static int +msg_write_parent(const char *info, struct msg_fds *fds, void *msg, size_t len) +{ + ssize_t rv; + CLOSEFD(fds->pfd[1]); + CLOSEFD(fds->cfd[0]); + + printf("Send %s\n", info); + rv = write(fds->cfd[1], msg, len); + if (rv != (ssize_t)len) + return 1; +// printf("Wait %s\n", info); + rv = read(fds->pfd[0], msg, len); + if (rv != (ssize_t)len) + return 1; + return 0; +} + +static int +msg_read_parent(const char *info, struct msg_fds *fds, void *msg, size_t len) +{ + ssize_t rv; + CLOSEFD(fds->pfd[1]); + CLOSEFD(fds->cfd[0]); + + printf("Wait %s\n", info); + rv = read(fds->pfd[0], msg, len); + if (rv != (ssize_t)len) + return 1; +// printf("Send %s\n", info); + rv = write(fds->cfd[1], msg, len); + if (rv != (ssize_t)len) + return 1; + return 0; +} + +static int +msg_read_child(const char *info, struct msg_fds *fds, void *msg, size_t len) +{ + ssize_t rv; + CLOSEFD(fds->cfd[1]); + CLOSEFD(fds->pfd[0]); + + printf("Wait %s\n", info); + rv = read(fds->cfd[0], msg, len); + if (rv != (ssize_t)len) + return 1; +// printf("Send %s\n", info); + rv = write(fds->pfd[1], msg, len); + if (rv != (ssize_t)len) + return 1; + return 0; +} diff --git a/contrib/netbsd-tests/kernel/t_mqueue.c b/contrib/netbsd-tests/kernel/t_mqueue.c index aa98d91..485269f 100644 --- a/contrib/netbsd-tests/kernel/t_mqueue.c +++ b/contrib/netbsd-tests/kernel/t_mqueue.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_mqueue.c,v 1.4 2014/03/02 19:56:48 jmmv Exp $ */ +/* $NetBSD: t_mqueue.c,v 1.5 2017/01/10 22:10:22 christos Exp $ */ /* * Test for POSIX message queue priority handling. @@ -14,6 +14,7 @@ #endif #include +#include #include #include diff --git a/contrib/netbsd-tests/kernel/t_ptrace.c b/contrib/netbsd-tests/kernel/t_ptrace.c new file mode 100644 index 0000000..074a953 --- /dev/null +++ b/contrib/netbsd-tests/kernel/t_ptrace.c @@ -0,0 +1,208 @@ +/* $NetBSD: t_ptrace.c,v 1.17 2016/11/13 22:59:31 kamil Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#include +__RCSID("$NetBSD: t_ptrace.c,v 1.17 2016/11/13 22:59:31 kamil Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "../h_macros.h" + +/* + * A child process cannot call atf functions and expect them to magically + * work like in the parent. + * The printf(3) messaging from a child will not work out of the box as well + * without estabilishing a communication protocol with its parent. To not + * overcomplicate the tests - do not log from a child and use err(3)/errx(3) + * wrapped with FORKEE_ASSERT()/FORKEE_ASSERTX() as that is guaranteed to work. + */ +#define FORKEE_ASSERTX(x) \ +do { \ + int ret = (x); \ + if (!ret) \ + errx(EXIT_FAILURE, "%s:%d %s(): Assertion failed for: %s", \ + __FILE__, __LINE__, __func__, #x); \ +} while (0) + +#define FORKEE_ASSERT(x) \ +do { \ + int ret = (x); \ + if (!ret) \ + err(EXIT_FAILURE, "%s:%d %s(): Assertion failed for: %s", \ + __FILE__, __LINE__, __func__, #x); \ +} while (0) + +ATF_TC(attach_pid0); +ATF_TC_HEAD(attach_pid0, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Assert that a debugger cannot attach to PID 0"); +} + +ATF_TC_BODY(attach_pid0, tc) +{ + errno = 0; + ATF_REQUIRE_ERRNO(EPERM, ptrace(PT_ATTACH, 0, NULL, 0) == -1); +} + +ATF_TC(attach_pid1); +ATF_TC_HEAD(attach_pid1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Assert that a debugger cannot attach to PID 1 (as non-root)"); + + atf_tc_set_md_var(tc, "require.user", "unprivileged"); +} + +ATF_TC_BODY(attach_pid1, tc) +{ + ATF_REQUIRE_ERRNO(EPERM, ptrace(PT_ATTACH, 1, NULL, 0) == -1); +} + +ATF_TC(attach_pid1_securelevel); +ATF_TC_HEAD(attach_pid1_securelevel, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Assert that a debugger cannot attach to PID 1 with " + "securelevel >= 1 (as root)"); + + atf_tc_set_md_var(tc, "require.user", "root"); +} + +ATF_TC_BODY(attach_pid1_securelevel, tc) +{ + int level; + size_t len = sizeof(level); + + ATF_REQUIRE(sysctlbyname("kern.securelevel", &level, &len, NULL, 0) + != -1); + + if (level < 1) { + atf_tc_skip("Test must be run with securelevel >= 1"); + } + + ATF_REQUIRE_ERRNO(EPERM, ptrace(PT_ATTACH, 1, NULL, 0) == -1); +} + +ATF_TC(attach_self); +ATF_TC_HEAD(attach_self, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Assert that a debugger cannot attach to self (as it's nonsense)"); +} + +ATF_TC_BODY(attach_self, tc) +{ + ATF_REQUIRE_ERRNO(EINVAL, ptrace(PT_ATTACH, getpid(), NULL, 0) == -1); +} + +ATF_TC(attach_chroot); +ATF_TC_HEAD(attach_chroot, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Assert that a debugger cannot trace another process unless the " + "process's root directory is at or below the tracing process's " + "root"); + + atf_tc_set_md_var(tc, "require.user", "root"); +} + +ATF_TC_BODY(attach_chroot, tc) +{ + char buf[PATH_MAX]; + pid_t child; + int fds_toparent[2], fds_fromparent[2]; + int rv; + uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ + + (void)memset(buf, '\0', sizeof(buf)); + ATF_REQUIRE(getcwd(buf, sizeof(buf)) != NULL); + (void)strlcat(buf, "/dir", sizeof(buf)); + + ATF_REQUIRE(mkdir(buf, 0500) == 0); + ATF_REQUIRE(chdir(buf) == 0); + + ATF_REQUIRE(pipe(fds_toparent) == 0); + ATF_REQUIRE(pipe(fds_fromparent) == 0); + child = atf_utils_fork(); + if (child == 0) { + FORKEE_ASSERT(close(fds_toparent[0]) == 0); + FORKEE_ASSERT(close(fds_fromparent[1]) == 0); + + FORKEE_ASSERT(chroot(buf) == 0); + + rv = write(fds_toparent[1], &msg, sizeof(msg)); + FORKEE_ASSERTX(rv == sizeof(msg)); + + ATF_REQUIRE_ERRNO(EPERM, + ptrace(PT_ATTACH, getppid(), NULL, 0) == -1); + + rv = read(fds_fromparent[0], &msg, sizeof(msg)); + FORKEE_ASSERTX(rv == sizeof(msg)); + + _exit(0); + } + ATF_REQUIRE(close(fds_toparent[1]) == 0); + ATF_REQUIRE(close(fds_fromparent[0]) == 0); + + printf("Waiting for chrooting of the child PID %d", child); + rv = read(fds_toparent[0], &msg, sizeof(msg)); + ATF_REQUIRE(rv == sizeof(msg)); + + printf("Child is ready, it will try to PT_ATTACH to parent\n"); + rv = write(fds_fromparent[1], &msg, sizeof(msg)); + ATF_REQUIRE(rv == sizeof(msg)); + + printf("fds_fromparent is no longer needed - close it\n"); + ATF_REQUIRE(close(fds_fromparent[1]) == 0); + + printf("fds_toparent is no longer needed - close it\n"); + ATF_REQUIRE(close(fds_toparent[0]) == 0); +} + +ATF_TP_ADD_TCS(tp) +{ + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); + ATF_TP_ADD_TC(tp, attach_pid0); + ATF_TP_ADD_TC(tp, attach_pid1); + ATF_TP_ADD_TC(tp, attach_pid1_securelevel); + ATF_TP_ADD_TC(tp, attach_self); + ATF_TP_ADD_TC(tp, attach_chroot); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/kernel/t_ptrace_wait.c b/contrib/netbsd-tests/kernel/t_ptrace_wait.c new file mode 100644 index 0000000..e502a03 --- /dev/null +++ b/contrib/netbsd-tests/kernel/t_ptrace_wait.c @@ -0,0 +1,5082 @@ +/* $NetBSD: t_ptrace_wait.c,v 1.53 2017/01/10 05:08:24 kamil Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#include +__RCSID("$NetBSD: t_ptrace_wait.c,v 1.53 2017/01/10 05:08:24 kamil Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "../h_macros.h" + +#include "t_ptrace_wait.h" +#include "msg.h" + +#define PARENT_TO_CHILD(info, fds, msg) \ + ATF_REQUIRE(msg_write_child(info " to child " # fds, &fds, &msg, sizeof(msg)) == 0) + +#define CHILD_FROM_PARENT(info, fds, msg) \ + FORKEE_ASSERT(msg_read_parent(info " from parent " # fds, &fds, &msg, sizeof(msg)) == 0) + +#define CHILD_TO_PARENT(info, fds, msg) \ + FORKEE_ASSERT(msg_write_parent(info " to parent " # fds, &fds, &msg, sizeof(msg)) == 0) + +#define PARENT_FROM_CHILD(info, fds, msg) \ + ATF_REQUIRE(msg_read_child(info " from parent " # fds, &fds, &msg, sizeof(msg)) == 0) + +ATF_TC(traceme1); +ATF_TC_HEAD(traceme1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify SIGSTOP followed by _exit(2) in a child"); +} + +ATF_TC_BODY(traceme1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(traceme2); +ATF_TC_HEAD(traceme2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify SIGSTOP followed by _exit(2) in a child"); +} + +static int traceme2_caught = 0; + +static void +traceme2_sighandler(int sig) +{ + FORKEE_ASSERT_EQ(sig, SIGINT); + + ++traceme2_caught; +} + +ATF_TC_BODY(traceme2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP, sigsent = SIGINT; + pid_t child, wpid; + struct sigaction sa; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + sa.sa_handler = traceme2_sighandler; + sa.sa_flags = SA_SIGINFO; + sigemptyset(&sa.sa_mask); + + FORKEE_ASSERT(sigaction(sigsent, &sa, NULL) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(traceme2_caught, 1); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Before resuming the child process where it left off and with " + "signal %s to be sent\n", strsignal(sigsent)); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigsent) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the exited child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(traceme3); +ATF_TC_HEAD(traceme3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify SIGSTOP followed by termination by a signal in a child"); +} + +ATF_TC_BODY(traceme3, tc) +{ + const int sigval = SIGSTOP, sigsent = SIGINT /* Without core-dump */; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + /* NOTREACHED */ + FORKEE_ASSERTX(0 && + "Child should be terminated by a signal from its parent"); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Before resuming the child process where it left off and with " + "signal %s to be sent\n", strsignal(sigsent)); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigsent) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_signaled(status, sigsent, 0); + + printf("Before calling %s() for the exited child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(traceme4); +ATF_TC_HEAD(traceme4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify SIGSTOP followed by SIGCONT and _exit(2) in a child"); +} + +ATF_TC_BODY(traceme4, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP, sigsent = SIGCONT; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before raising %s from child\n", strsignal(sigsent)); + FORKEE_ASSERT(raise(sigsent) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(),child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigsent); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the exited child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +#if defined(TWAIT_HAVE_PID) +ATF_TC(attach1); +ATF_TC_HEAD(attach1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Assert that tracer sees process termination before the parent"); +} + +ATF_TC_BODY(attach1, tc) +{ + struct msg_fds parent_tracee, parent_tracer; + const int exitval_tracee = 5; + const int exitval_tracer = 10; + pid_t tracee, tracer, wpid; + uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Spawn tracee\n"); + ATF_REQUIRE(msg_open(&parent_tracee) == 0); + tracee = atf_utils_fork(); + if (tracee == 0) { + // Wait for parent to let us exit + CHILD_FROM_PARENT("exit tracee", parent_tracee, msg); + _exit(exitval_tracee); + } + + printf("Spawn debugger\n"); + ATF_REQUIRE(msg_open(&parent_tracer) == 0); + tracer = atf_utils_fork(); + if (tracer == 0) { + printf("Before calling PT_ATTACH from tracee %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1); + + /* Wait for tracee and assert that it was stopped w/ SIGSTOP */ + FORKEE_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); + + forkee_status_stopped(status, SIGSTOP); + + /* Resume tracee with PT_CONTINUE */ + FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1); + + /* Inform parent that tracer has attached to tracee */ + CHILD_TO_PARENT("tracer ready", parent_tracer, msg); + + /* Wait for parent to tell use that tracee should have exited */ + CHILD_FROM_PARENT("wait for tracee exit", parent_tracer, msg); + + /* Wait for tracee and assert that it exited */ + FORKEE_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); + + forkee_status_exited(status, exitval_tracee); + printf("Tracee %d exited with %d\n", tracee, exitval_tracee); + + printf("Before exiting of the tracer process\n"); + _exit(exitval_tracer); + } + + printf("Wait for the tracer to attach to the tracee\n"); + PARENT_FROM_CHILD("tracer ready", parent_tracer, msg); + + printf("Resume the tracee and let it exit\n"); + PARENT_TO_CHILD("exit tracee", parent_tracee, msg); + + printf("Detect that tracee is zombie\n"); + await_zombie(tracee); + + + printf("Assert that there is no status about tracee %d - " + "Tracer must detect zombie first - calling %s()\n", tracee, + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0); + + printf("Tell the tracer child should have exited\n"); + PARENT_TO_CHILD("wait for tracee exit", parent_tracer, msg); + printf("Wait for tracer to finish its job and exit - calling %s()\n", + TWAIT_FNAME); + + printf("Wait from tracer child to complete waiting for tracee\n"); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0), + tracer); + + validate_status_exited(status, exitval_tracer); + + printf("Wait for tracee to finish its job and exit - calling %s()\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), + tracee); + + validate_status_exited(status, exitval_tracee); + + msg_close(&parent_tracer); + msg_close(&parent_tracee); +} +#endif + +#if defined(TWAIT_HAVE_PID) +ATF_TC(attach2); +ATF_TC_HEAD(attach2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Assert that any tracer sees process termination before its " + "parent"); +} + +ATF_TC_BODY(attach2, tc) +{ + struct msg_fds parent_tracer, parent_tracee; + const int exitval_tracee = 5; + const int exitval_tracer1 = 10, exitval_tracer2 = 20; + pid_t tracee, tracer, wpid; + uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Spawn tracee\n"); + ATF_REQUIRE(msg_open(&parent_tracee) == 0); + tracee = atf_utils_fork(); + if (tracee == 0) { + /* Wait for message from the parent */ + CHILD_FROM_PARENT("Message 1", parent_tracee, msg); + _exit(exitval_tracee); + } + + printf("Spawn debugger\n"); + ATF_REQUIRE(msg_open(&parent_tracer) == 0); + tracer = atf_utils_fork(); + if (tracer == 0) { + /* Fork again and drop parent to reattach to PID 1 */ + tracer = atf_utils_fork(); + if (tracer != 0) + _exit(exitval_tracer1); + + printf("Before calling PT_ATTACH from tracee %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1); + + /* Wait for tracee and assert that it was stopped w/ SIGSTOP */ + FORKEE_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); + + forkee_status_stopped(status, SIGSTOP); + + /* Resume tracee with PT_CONTINUE */ + FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1); + + /* Inform parent that tracer has attached to tracee */ + CHILD_TO_PARENT("Message 1", parent_tracer, msg); + CHILD_FROM_PARENT("Message 2", parent_tracer, msg); + + /* Wait for tracee and assert that it exited */ + FORKEE_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); + + forkee_status_exited(status, exitval_tracee); + + printf("Before exiting of the tracer process\n"); + _exit(exitval_tracer2); + } + printf("Wait for the tracer process (direct child) to exit calling " + "%s()\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracer, &status, 0), tracer); + + validate_status_exited(status, exitval_tracer1); + + printf("Wait for the non-exited tracee process with %s()\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, NULL, WNOHANG), 0); + + printf("Wait for the tracer to attach to the tracee\n"); + PARENT_FROM_CHILD("Message 1", parent_tracer, msg); + printf("Resume the tracee and let it exit\n"); + PARENT_TO_CHILD("Message 1", parent_tracee, msg); + + printf("Detect that tracee is zombie\n"); + await_zombie(tracee); + + printf("Assert that there is no status about tracee - " + "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0); + + printf("Resume the tracer and let it detect exited tracee\n"); + PARENT_TO_CHILD("Message 2", parent_tracer, msg); + + printf("Wait for tracee to finish its job and exit - calling %s()\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), + tracee); + + validate_status_exited(status, exitval_tracee); + + msg_close(&parent_tracer); + msg_close(&parent_tracee); + +} +#endif + +ATF_TC(attach3); +ATF_TC_HEAD(attach3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Assert that tracer parent can PT_ATTACH to its child"); +} + +ATF_TC_BODY(attach3, tc) +{ + struct msg_fds parent_tracee; + const int exitval_tracee = 5; + pid_t tracee, wpid; + uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Spawn tracee\n"); + ATF_REQUIRE(msg_open(&parent_tracee) == 0); + tracee = atf_utils_fork(); + if (tracee == 0) { + CHILD_FROM_PARENT("Message 1", parent_tracee, msg); + printf("Parent should now attach to tracee\n"); + + CHILD_FROM_PARENT("Message 2", parent_tracee, msg); + /* Wait for message from the parent */ + _exit(exitval_tracee); + } + PARENT_TO_CHILD("Message 1", parent_tracee, msg); + + printf("Before calling PT_ATTACH for tracee %d\n", tracee); + ATF_REQUIRE(ptrace(PT_ATTACH, tracee, NULL, 0) != -1); + + printf("Wait for the stopped tracee process with %s()\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); + + validate_status_stopped(status, SIGSTOP); + + printf("Resume tracee with PT_CONTINUE\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1); + + printf("Let the tracee exit now\n"); + PARENT_TO_CHILD("Message 2", parent_tracee, msg); + + printf("Wait for tracee to exit with %s()\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); + + validate_status_exited(status, exitval_tracee); + + printf("Before calling %s() for tracee\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, + wpid = TWAIT_GENERIC(tracee, &status, 0)); + + msg_close(&parent_tracee); +} + +ATF_TC(attach4); +ATF_TC_HEAD(attach4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Assert that tracer child can PT_ATTACH to its parent"); +} + +ATF_TC_BODY(attach4, tc) +{ + struct msg_fds parent_tracee; + const int exitval_tracer = 5; + pid_t tracer, wpid; + uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Spawn tracer\n"); + ATF_REQUIRE(msg_open(&parent_tracee) == 0); + tracer = atf_utils_fork(); + if (tracer == 0) { + + /* Wait for message from the parent */ + CHILD_FROM_PARENT("Message 1", parent_tracee, msg); + + printf("Attach to parent PID %d with PT_ATTACH from child\n", + getppid()); + FORKEE_ASSERT(ptrace(PT_ATTACH, getppid(), NULL, 0) != -1); + + printf("Wait for the stopped parent process with %s()\n", + TWAIT_FNAME); + FORKEE_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(getppid(), &status, 0), getppid()); + + forkee_status_stopped(status, SIGSTOP); + + printf("Resume parent with PT_DETACH\n"); + FORKEE_ASSERT(ptrace(PT_DETACH, getppid(), (void *)1, 0) + != -1); + + /* Tell parent we are ready */ + CHILD_TO_PARENT("Message 1", parent_tracee, msg); + + _exit(exitval_tracer); + } + + printf("Wait for the tracer to become ready\n"); + PARENT_TO_CHILD("Message 1", parent_tracee, msg); + printf("Allow the tracer to exit now\n"); + PARENT_FROM_CHILD("Message 1", parent_tracee, msg); + + printf("Wait for tracer to exit with %s()\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracer, &status, 0), tracer); + + validate_status_exited(status, exitval_tracer); + + printf("Before calling %s() for tracer\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, + wpid = TWAIT_GENERIC(tracer, &status, 0)); + + msg_close(&parent_tracee); +} + +#if defined(TWAIT_HAVE_PID) +ATF_TC(attach5); +ATF_TC_HEAD(attach5, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Assert that tracer sees its parent when attached to tracer " + "(check getppid(2))"); +} + +ATF_TC_BODY(attach5, tc) +{ + struct msg_fds parent_tracer, parent_tracee; + const int exitval_tracee = 5; + const int exitval_tracer = 10; + pid_t parent, tracee, tracer, wpid; + uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Spawn tracee\n"); + ATF_REQUIRE(msg_open(&parent_tracer) == 0); + ATF_REQUIRE(msg_open(&parent_tracee) == 0); + tracee = atf_utils_fork(); + if (tracee == 0) { + parent = getppid(); + + /* Emit message to the parent */ + CHILD_TO_PARENT("tracee ready", parent_tracee, msg); + CHILD_FROM_PARENT("exit tracee", parent_tracee, msg); + + FORKEE_ASSERT_EQ(parent, getppid()); + + _exit(exitval_tracee); + } + printf("Wait for child to record its parent identifier (pid)\n"); + PARENT_FROM_CHILD("tracee ready", parent_tracee, msg); + + printf("Spawn debugger\n"); + tracer = atf_utils_fork(); + if (tracer == 0) { + /* No IPC to communicate with the child */ + printf("Before calling PT_ATTACH from tracee %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1); + + /* Wait for tracee and assert that it was stopped w/ SIGSTOP */ + FORKEE_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); + + forkee_status_stopped(status, SIGSTOP); + + /* Resume tracee with PT_CONTINUE */ + FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1); + + /* Inform parent that tracer has attached to tracee */ + CHILD_TO_PARENT("tracer ready", parent_tracer, msg); + + /* Wait for parent to tell use that tracee should have exited */ + CHILD_FROM_PARENT("wait for tracee exit", parent_tracer, msg); + + /* Wait for tracee and assert that it exited */ + FORKEE_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); + + forkee_status_exited(status, exitval_tracee); + + printf("Before exiting of the tracer process\n"); + _exit(exitval_tracer); + } + + printf("Wait for the tracer to attach to the tracee\n"); + PARENT_FROM_CHILD("tracer ready", parent_tracer, msg); + + printf("Resume the tracee and let it exit\n"); + PARENT_TO_CHILD("exit tracee", parent_tracee, msg); + + printf("Detect that tracee is zombie\n"); + await_zombie(tracee); + + printf("Assert that there is no status about tracee - " + "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0); + + printf("Tell the tracer child should have exited\n"); + PARENT_TO_CHILD("wait for tracee exit", parent_tracer, msg); + + printf("Wait from tracer child to complete waiting for tracee\n"); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0), + tracer); + + validate_status_exited(status, exitval_tracer); + + printf("Wait for tracee to finish its job and exit - calling %s()\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), + tracee); + + validate_status_exited(status, exitval_tracee); + + msg_close(&parent_tracer); + msg_close(&parent_tracee); +} +#endif + +#if defined(TWAIT_HAVE_PID) +ATF_TC(attach6); +ATF_TC_HEAD(attach6, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Assert that tracer sees its parent when attached to tracer " + "(check sysctl(7) and struct kinfo_proc2)"); +} + +ATF_TC_BODY(attach6, tc) +{ + struct msg_fds parent_tracee, parent_tracer; + const int exitval_tracee = 5; + const int exitval_tracer = 10; + pid_t parent, tracee, tracer, wpid; + uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + int name[CTL_MAXNAME]; + struct kinfo_proc2 kp; + size_t len = sizeof(kp); + unsigned int namelen; + + printf("Spawn tracee\n"); + ATF_REQUIRE(msg_open(&parent_tracee) == 0); + ATF_REQUIRE(msg_open(&parent_tracer) == 0); + tracee = atf_utils_fork(); + if (tracee == 0) { + parent = getppid(); + + /* Emit message to the parent */ + CHILD_TO_PARENT("Message 1", parent_tracee, msg); + CHILD_FROM_PARENT("Message 2", parent_tracee, msg); + + namelen = 0; + name[namelen++] = CTL_KERN; + name[namelen++] = KERN_PROC2; + name[namelen++] = KERN_PROC_PID; + name[namelen++] = getpid(); + name[namelen++] = len; + name[namelen++] = 1; + + FORKEE_ASSERT(sysctl(name, namelen, &kp, &len, NULL, 0) == 0); + FORKEE_ASSERT_EQ(parent, kp.p_ppid); + + _exit(exitval_tracee); + } + + printf("Wait for child to record its parent identifier (pid)\n"); + PARENT_FROM_CHILD("Message 1", parent_tracee, msg); + + printf("Spawn debugger\n"); + tracer = atf_utils_fork(); + if (tracer == 0) { + /* No IPC to communicate with the child */ + printf("Before calling PT_ATTACH from tracee %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1); + + /* Wait for tracee and assert that it was stopped w/ SIGSTOP */ + FORKEE_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); + + forkee_status_stopped(status, SIGSTOP); + + /* Resume tracee with PT_CONTINUE */ + FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1); + + /* Inform parent that tracer has attached to tracee */ + CHILD_TO_PARENT("Message 1", parent_tracer, msg); + + CHILD_FROM_PARENT("Message 2", parent_tracer, msg); + + /* Wait for tracee and assert that it exited */ + FORKEE_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); + + forkee_status_exited(status, exitval_tracee); + + printf("Before exiting of the tracer process\n"); + _exit(exitval_tracer); + } + + printf("Wait for the tracer to attach to the tracee\n"); + PARENT_FROM_CHILD("Message 1", parent_tracer, msg); + + printf("Resume the tracee and let it exit\n"); + PARENT_TO_CHILD("Message 1", parent_tracee, msg); + + printf("Detect that tracee is zombie\n"); + await_zombie(tracee); + + printf("Assert that there is no status about tracee - " + "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0); + + printf("Resume the tracer and let it detect exited tracee\n"); + PARENT_TO_CHILD("Message 2", parent_tracer, msg); + + printf("Wait for tracer to finish its job and exit - calling %s()\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0), + tracer); + + validate_status_exited(status, exitval_tracer); + + printf("Wait for tracee to finish its job and exit - calling %s()\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), + tracee); + + validate_status_exited(status, exitval_tracee); + + msg_close(&parent_tracee); + msg_close(&parent_tracer); +} +#endif + +#if defined(TWAIT_HAVE_PID) +ATF_TC(attach7); +ATF_TC_HEAD(attach7, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Assert that tracer sees its parent when attached to tracer " + "(check /proc/curproc/status 3rd column)"); +} + +ATF_TC_BODY(attach7, tc) +{ + struct msg_fds parent_tracee, parent_tracer; + int rv; + const int exitval_tracee = 5; + const int exitval_tracer = 10; + pid_t parent, tracee, tracer, wpid; + uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + FILE *fp; + struct stat st; + const char *fname = "/proc/curproc/status"; + char s_executable[MAXPATHLEN]; + int s_pid, s_ppid; + /* + * Format: + * EXECUTABLE PID PPID ... + */ + + ATF_REQUIRE((rv = stat(fname, &st)) == 0 || (errno == ENOENT)); + if (rv != 0) { + atf_tc_skip("/proc/curproc/status not found"); + } + + printf("Spawn tracee\n"); + ATF_REQUIRE(msg_open(&parent_tracee) == 0); + ATF_REQUIRE(msg_open(&parent_tracer) == 0); + tracee = atf_utils_fork(); + if (tracee == 0) { + parent = getppid(); + + // Wait for parent to let us exit + CHILD_TO_PARENT("tracee ready", parent_tracee, msg); + CHILD_FROM_PARENT("tracee exit", parent_tracee, msg); + + FORKEE_ASSERT((fp = fopen(fname, "r")) != NULL); + fscanf(fp, "%s %d %d", s_executable, &s_pid, &s_ppid); + FORKEE_ASSERT(fclose(fp) == 0); + FORKEE_ASSERT_EQ(parent, s_ppid); + + _exit(exitval_tracee); + } + + printf("Wait for child to record its parent identifier (pid)\n"); + PARENT_FROM_CHILD("tracee ready", parent_tracee, msg); + + printf("Spawn debugger\n"); + tracer = atf_utils_fork(); + if (tracer == 0) { + printf("Before calling PT_ATTACH from tracee %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1); + + /* Wait for tracee and assert that it was stopped w/ SIGSTOP */ + FORKEE_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); + + forkee_status_stopped(status, SIGSTOP); + + /* Resume tracee with PT_CONTINUE */ + FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1); + + /* Inform parent that tracer has attached to tracee */ + CHILD_TO_PARENT("tracer ready", parent_tracer, msg); + + /* Wait for parent to tell use that tracee should have exited */ + CHILD_FROM_PARENT("wait for tracee exit", parent_tracer, msg); + + /* Wait for tracee and assert that it exited */ + FORKEE_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); + + forkee_status_exited(status, exitval_tracee); + + printf("Before exiting of the tracer process\n"); + _exit(exitval_tracer); + } + printf("Wait for the tracer to attach to the tracee\n"); + PARENT_FROM_CHILD("tracer ready", parent_tracer, msg); + printf("Resume the tracee and let it exit\n"); + PARENT_TO_CHILD("tracee exit", parent_tracee, msg); + + printf("Detect that tracee is zombie\n"); + await_zombie(tracee); + + printf("Assert that there is no status about tracee - " + "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0); + + printf("Resume the tracer and let it detect exited tracee\n"); + PARENT_TO_CHILD("Message 2", parent_tracer, msg); + + printf("Wait for tracer to finish its job and exit - calling %s()\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0), + tracer); + + validate_status_exited(status, exitval_tracer); + + printf("Wait for tracee to finish its job and exit - calling %s()\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), + tracee); + + validate_status_exited(status, exitval_tracee); + + msg_close(&parent_tracee); + msg_close(&parent_tracer); +} +#endif + +ATF_TC(eventmask1); +ATF_TC_HEAD(eventmask1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that empty EVENT_MASK is preserved"); +} + +ATF_TC_BODY(eventmask1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + ptrace_event_t set_event, get_event; + const int len = sizeof(ptrace_event_t); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + set_event.pe_set_event = 0; + ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1); + ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1); + ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(eventmask2); +ATF_TC_HEAD(eventmask2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that PTRACE_FORK in EVENT_MASK is preserved"); +} + +ATF_TC_BODY(eventmask2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + ptrace_event_t set_event, get_event; + const int len = sizeof(ptrace_event_t); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + set_event.pe_set_event = PTRACE_FORK; + ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1); + ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1); + ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +#if defined(TWAIT_HAVE_PID) +ATF_TC(fork1); +ATF_TC_HEAD(fork1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that fork(2) is intercepted by ptrace(2) with EVENT_MASK " + "set to PTRACE_FORK"); +} + +ATF_TC_BODY(fork1, tc) +{ + const int exitval = 5; + const int exitval2 = 15; + const int sigval = SIGSTOP; + pid_t child, child2, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + ptrace_state_t state; + const int slen = sizeof(state); + ptrace_event_t event; + const int elen = sizeof(event); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT((child2 = fork()) != 1); + + if (child2 == 0) + _exit(exitval2); + + FORKEE_REQUIRE_SUCCESS + (wpid = TWAIT_GENERIC(child2, &status, 0), child2); + + forkee_status_exited(status, exitval2); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Enable PTRACE_FORK in EVENT_MASK for the child %d\n", child); + event.pe_set_event = PTRACE_FORK; + ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1); + ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK); + + child2 = state.pe_other_pid; + printf("Reported PTRACE_FORK event with forkee %d\n", child2); + + printf("Before calling %s() for the forkee %d of the child %d\n", + TWAIT_FNAME, child2, child); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0), + child2); + + validate_status_stopped(status, SIGTRAP); + + ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child2, &state, slen) != -1); + ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK); + ATF_REQUIRE_EQ(state.pe_other_pid, child); + + printf("Before resuming the forkee process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child2, (void *)1, 0) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the forkee - expected exited\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0), + child2); + + validate_status_exited(status, exitval2); + + printf("Before calling %s() for the forkee - expected no process\n", + TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, + wpid = TWAIT_GENERIC(child2, &status, 0)); + + printf("Before calling %s() for the child - expected stopped " + "SIGCHLD\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGCHLD); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child - expected exited\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child - expected no process\n", + TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +ATF_TC(fork2); +ATF_TC_HEAD(fork2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that fork(2) is not intercepted by ptrace(2) with empty " + "EVENT_MASK"); +} + +ATF_TC_BODY(fork2, tc) +{ + const int exitval = 5; + const int exitval2 = 15; + const int sigval = SIGSTOP; + pid_t child, child2, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + ptrace_event_t event; + const int elen = sizeof(event); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT((child2 = fork()) != 1); + + if (child2 == 0) + _exit(exitval2); + + FORKEE_REQUIRE_SUCCESS + (wpid = TWAIT_GENERIC(child2, &status, 0), child2); + + forkee_status_exited(status, exitval2); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Set empty EVENT_MASK for the child %d\n", child); + event.pe_set_event = 0; + ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child - expected stopped " + "SIGCHLD\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGCHLD); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child - expected exited\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child - expected no process\n", + TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +#if defined(TWAIT_HAVE_PID) +ATF_TC(vfork1); +ATF_TC_HEAD(vfork1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK " + "set to PTRACE_VFORK"); +} + +ATF_TC_BODY(vfork1, tc) +{ + const int exitval = 5; + const int exitval2 = 15; + const int sigval = SIGSTOP; + pid_t child, child2, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + ptrace_state_t state; + const int slen = sizeof(state); + ptrace_event_t event; + const int elen = sizeof(event); + + /* + * ptrace(2) command PT_SET_EVENT_MASK: option PTRACE_VFORK unsupported + */ +#ifndef PTRACE_VFORK +#define PTRACE_VFORK 0 +#endif + atf_tc_expect_fail("PR kern/51630"); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT((child2 = vfork()) != 1); + + if (child2 == 0) + _exit(exitval2); + + FORKEE_REQUIRE_SUCCESS + (wpid = TWAIT_GENERIC(child2, &status, 0), child2); + + forkee_status_exited(status, exitval2); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Enable PTRACE_VFORK in EVENT_MASK for the child %d\n", child); + event.pe_set_event = PTRACE_VFORK; + ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1); + ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_VFORK); + + child2 = state.pe_other_pid; + printf("Reported PTRACE_VFORK event with forkee %d\n", child2); + + printf("Before calling %s() for the forkee %d of the child %d\n", + TWAIT_FNAME, child2, child); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0), + child2); + + validate_status_stopped(status, SIGTRAP); + + ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child2, &state, slen) != -1); + ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_VFORK); + ATF_REQUIRE_EQ(state.pe_other_pid, child); + + printf("Before resuming the forkee process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child2, (void *)1, 0) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the forkee - expected exited\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0), + child2); + + validate_status_exited(status, exitval2); + + printf("Before calling %s() for the forkee - expected no process\n", + TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, + wpid = TWAIT_GENERIC(child2, &status, 0)); + + printf("Before calling %s() for the child - expected stopped " + "SIGCHLD\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGCHLD); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child - expected exited\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child - expected no process\n", + TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +ATF_TC(vfork2); +ATF_TC_HEAD(vfork2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that vfork(2) is not intercepted by ptrace(2) with empty " + "EVENT_MASK"); +} + +ATF_TC_BODY(vfork2, tc) +{ + const int exitval = 5; + const int exitval2 = 15; + const int sigval = SIGSTOP; + pid_t child, child2, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + ptrace_event_t event; + const int elen = sizeof(event); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT((child2 = vfork()) != 1); + + if (child2 == 0) + _exit(exitval2); + + FORKEE_REQUIRE_SUCCESS + (wpid = TWAIT_GENERIC(child2, &status, 0), child2); + + forkee_status_exited(status, exitval2); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Set empty EVENT_MASK for the child %d\n", child); + event.pe_set_event = 0; + ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child - expected stopped " + "SIGCHLD\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGCHLD); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child - expected exited\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child - expected no process\n", + TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(io_read_d1); +ATF_TC_HEAD(io_read_d1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_IO with PIOD_READ_D and len = sizeof(uint8_t)"); +} + +ATF_TC_BODY(io_read_d1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + uint8_t lookup_me = 0; + const uint8_t magic = 0xab; + struct ptrace_io_desc io = { + .piod_op = PIOD_READ_D, + .piod_offs = &lookup_me, + .piod_addr = &lookup_me, + .piod_len = sizeof(lookup_me) + }; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + lookup_me = magic; + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); + + ATF_REQUIRE_EQ_MSG(lookup_me, magic, + "got value %" PRIx8 " != expected %" PRIx8, lookup_me, magic); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(io_read_d2); +ATF_TC_HEAD(io_read_d2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_IO with PIOD_READ_D and len = sizeof(uint16_t)"); +} + +ATF_TC_BODY(io_read_d2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + uint16_t lookup_me = 0; + const uint16_t magic = 0x1234; + struct ptrace_io_desc io = { + .piod_op = PIOD_READ_D, + .piod_offs = &lookup_me, + .piod_addr = &lookup_me, + .piod_len = sizeof(lookup_me) + }; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + lookup_me = magic; + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); + + ATF_REQUIRE_EQ_MSG(lookup_me, magic, + "got value %" PRIx16 " != expected %" PRIx16, lookup_me, magic); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(io_read_d3); +ATF_TC_HEAD(io_read_d3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_IO with PIOD_READ_D and len = sizeof(uint32_t)"); +} + +ATF_TC_BODY(io_read_d3, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + uint32_t lookup_me = 0; + const uint32_t magic = 0x1234abcd; + struct ptrace_io_desc io = { + .piod_op = PIOD_READ_D, + .piod_offs = &lookup_me, + .piod_addr = &lookup_me, + .piod_len = sizeof(lookup_me) + }; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + lookup_me = magic; + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); + + ATF_REQUIRE_EQ_MSG(lookup_me, magic, + "got value %" PRIx32 " != expected %" PRIx32, lookup_me, magic); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(io_read_d4); +ATF_TC_HEAD(io_read_d4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_IO with PIOD_READ_D and len = sizeof(uint64_t)"); +} + +ATF_TC_BODY(io_read_d4, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + uint64_t lookup_me = 0; + const uint64_t magic = 0x1234abcd9876dcfa; + struct ptrace_io_desc io = { + .piod_op = PIOD_READ_D, + .piod_offs = &lookup_me, + .piod_addr = &lookup_me, + .piod_len = sizeof(lookup_me) + }; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + lookup_me = magic; + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); + + ATF_REQUIRE_EQ_MSG(lookup_me, magic, + "got value %" PRIx64 " != expected %" PRIx64, lookup_me, magic); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(io_write_d1); +ATF_TC_HEAD(io_write_d1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint8_t)"); +} + +ATF_TC_BODY(io_write_d1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + uint8_t lookup_me = 0; + const uint8_t magic = 0xab; + struct ptrace_io_desc io = { + .piod_op = PIOD_WRITE_D, + .piod_offs = &lookup_me, + .piod_addr = &lookup_me, + .piod_len = sizeof(lookup_me) + }; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(lookup_me, magic); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + lookup_me = magic; + + printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(io_write_d2); +ATF_TC_HEAD(io_write_d2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint16_t)"); +} + +ATF_TC_BODY(io_write_d2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + uint16_t lookup_me = 0; + const uint16_t magic = 0xab12; + struct ptrace_io_desc io = { + .piod_op = PIOD_WRITE_D, + .piod_offs = &lookup_me, + .piod_addr = &lookup_me, + .piod_len = sizeof(lookup_me) + }; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(lookup_me, magic); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + lookup_me = magic; + + printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(io_write_d3); +ATF_TC_HEAD(io_write_d3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint32_t)"); +} + +ATF_TC_BODY(io_write_d3, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + uint32_t lookup_me = 0; + const uint32_t magic = 0xab127643; + struct ptrace_io_desc io = { + .piod_op = PIOD_WRITE_D, + .piod_offs = &lookup_me, + .piod_addr = &lookup_me, + .piod_len = sizeof(lookup_me) + }; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(lookup_me, magic); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + lookup_me = magic; + + printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(io_write_d4); +ATF_TC_HEAD(io_write_d4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint64_t)"); +} + +ATF_TC_BODY(io_write_d4, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + uint64_t lookup_me = 0; + const uint64_t magic = 0xab12764376490123; + struct ptrace_io_desc io = { + .piod_op = PIOD_WRITE_D, + .piod_offs = &lookup_me, + .piod_addr = &lookup_me, + .piod_len = sizeof(lookup_me) + }; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(lookup_me, magic); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + lookup_me = magic; + + printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(read_d1); +ATF_TC_HEAD(read_d1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_READ_D called once"); +} + +ATF_TC_BODY(read_d1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + int lookup_me = 0; + const int magic = (int)random(); +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + lookup_me = magic; + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read new lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me = ptrace(PT_READ_D, child, &lookup_me, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me, magic, + "got value %#x != expected %#x", lookup_me, magic); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(read_d2); +ATF_TC_HEAD(read_d2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_READ_D called twice"); +} + +ATF_TC_BODY(read_d2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + int lookup_me1 = 0; + int lookup_me2 = 0; + const int magic1 = (int)random(); + const int magic2 = (int)random(); +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + lookup_me1 = magic1; + lookup_me2 = magic2; + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me1 = ptrace(PT_READ_D, child, &lookup_me1, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me1, magic1, + "got value %#x != expected %#x", lookup_me1, magic1); + + printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me2 = ptrace(PT_READ_D, child, &lookup_me2, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me2, magic2, + "got value %#x != expected %#x", lookup_me2, magic2); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(read_d3); +ATF_TC_HEAD(read_d3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_READ_D called three times"); +} + +ATF_TC_BODY(read_d3, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + int lookup_me1 = 0; + int lookup_me2 = 0; + int lookup_me3 = 0; + const int magic1 = (int)random(); + const int magic2 = (int)random(); + const int magic3 = (int)random(); +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + lookup_me1 = magic1; + lookup_me2 = magic2; + lookup_me3 = magic3; + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me1 = ptrace(PT_READ_D, child, &lookup_me1, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me1, magic1, + "got value %#x != expected %#x", lookup_me1, magic1); + + printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me2 = ptrace(PT_READ_D, child, &lookup_me2, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me2, magic2, + "got value %#x != expected %#x", lookup_me2, magic2); + + printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me3 = ptrace(PT_READ_D, child, &lookup_me3, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me3, magic3, + "got value %#x != expected %#x", lookup_me3, magic3); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(read_d4); +ATF_TC_HEAD(read_d4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_READ_D called four times"); +} + +ATF_TC_BODY(read_d4, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + int lookup_me1 = 0; + int lookup_me2 = 0; + int lookup_me3 = 0; + int lookup_me4 = 0; + const int magic1 = (int)random(); + const int magic2 = (int)random(); + const int magic3 = (int)random(); + const int magic4 = (int)random(); +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + lookup_me1 = magic1; + lookup_me2 = magic2; + lookup_me3 = magic3; + lookup_me4 = magic4; + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me1 = ptrace(PT_READ_D, child, &lookup_me1, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me1, magic1, + "got value %#x != expected %#x", lookup_me1, magic1); + + printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me2 = ptrace(PT_READ_D, child, &lookup_me2, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me2, magic2, + "got value %#x != expected %#x", lookup_me2, magic2); + + printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me3 = ptrace(PT_READ_D, child, &lookup_me3, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me3, magic3, + "got value %#x != expected %#x", lookup_me3, magic3); + + printf("Read new lookup_me4 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me4 = ptrace(PT_READ_D, child, &lookup_me4, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me4, magic4, + "got value %#x != expected %#x", lookup_me4, magic4); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(write_d1); +ATF_TC_HEAD(write_d1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_WRITE_D called once"); +} + +ATF_TC_BODY(write_d1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + int lookup_me = 0; + const int magic = (int)random(); +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(lookup_me, magic); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me, magic) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(write_d2); +ATF_TC_HEAD(write_d2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_WRITE_D called twice"); +} + +ATF_TC_BODY(write_d2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + int lookup_me1 = 0; + int lookup_me2 = 0; + const int magic1 = (int)random(); + const int magic2 = (int)random(); +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(lookup_me1, magic1); + FORKEE_ASSERT_EQ(lookup_me2, magic2); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Write new lookup_me1 to tracee (PID=%d) from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me1, magic1) != -1); + + printf("Write new lookup_me2 to tracee (PID=%d) from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me2, magic2) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(write_d3); +ATF_TC_HEAD(write_d3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_WRITE_D called three times"); +} + +ATF_TC_BODY(write_d3, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + int lookup_me1 = 0; + int lookup_me2 = 0; + int lookup_me3 = 0; + const int magic1 = (int)random(); + const int magic2 = (int)random(); + const int magic3 = (int)random(); +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(lookup_me1, magic1); + FORKEE_ASSERT_EQ(lookup_me2, magic2); + FORKEE_ASSERT_EQ(lookup_me3, magic3); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Write new lookup_me1 to tracee (PID=%d) from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me1, magic1) != -1); + + printf("Write new lookup_me2 to tracee (PID=%d) from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me2, magic2) != -1); + + printf("Write new lookup_me3 to tracee (PID=%d) from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me3, magic3) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(write_d4); +ATF_TC_HEAD(write_d4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_WRITE_D called four times"); +} + +ATF_TC_BODY(write_d4, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + int lookup_me1 = 0; + int lookup_me2 = 0; + int lookup_me3 = 0; + int lookup_me4 = 0; + const int magic1 = (int)random(); + const int magic2 = (int)random(); + const int magic3 = (int)random(); + const int magic4 = (int)random(); +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(lookup_me1, magic1); + FORKEE_ASSERT_EQ(lookup_me2, magic2); + FORKEE_ASSERT_EQ(lookup_me3, magic3); + FORKEE_ASSERT_EQ(lookup_me4, magic4); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Write new lookup_me1 to tracee (PID=%d) from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me1, magic1) != -1); + + printf("Write new lookup_me2 to tracee (PID=%d) from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me2, magic2) != -1); + + printf("Write new lookup_me3 to tracee (PID=%d) from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me3, magic3) != -1); + + printf("Write new lookup_me4 to tracee (PID=%d) from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me4, magic4) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(io_read_d_write_d_handshake1); +ATF_TC_HEAD(io_read_d_write_d_handshake1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_IO with PIOD_READ_D and PIOD_WRITE_D handshake"); +} + +ATF_TC_BODY(io_read_d_write_d_handshake1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + uint8_t lookup_me_fromtracee = 0; + const uint8_t magic_fromtracee = (uint8_t)random(); + uint8_t lookup_me_totracee = 0; + const uint8_t magic_totracee = (uint8_t)random(); + struct ptrace_io_desc io_fromtracee = { + .piod_op = PIOD_READ_D, + .piod_offs = &lookup_me_fromtracee, + .piod_addr = &lookup_me_fromtracee, + .piod_len = sizeof(lookup_me_fromtracee) + }; + struct ptrace_io_desc io_totracee = { + .piod_op = PIOD_WRITE_D, + .piod_offs = &lookup_me_totracee, + .piod_addr = &lookup_me_totracee, + .piod_len = sizeof(lookup_me_totracee) + }; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + lookup_me_fromtracee = magic_fromtracee; + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read lookup_me_fromtracee PID=%d by tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io_fromtracee, 0) != -1); + + ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee, + "got value %" PRIx8 " != expected %" PRIx8, lookup_me_fromtracee, + magic_fromtracee); + + lookup_me_totracee = magic_totracee; + + printf("Write lookup_me_totracee to PID=%d by tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io_totracee, 0) != -1); + + ATF_REQUIRE_EQ_MSG(lookup_me_totracee, magic_totracee, + "got value %" PRIx8 " != expected %" PRIx8, lookup_me_totracee, + magic_totracee); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(io_read_d_write_d_handshake2); +ATF_TC_HEAD(io_read_d_write_d_handshake2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_IO with PIOD_WRITE_D and PIOD_READ_D handshake"); +} + +ATF_TC_BODY(io_read_d_write_d_handshake2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + uint8_t lookup_me_fromtracee = 0; + const uint8_t magic_fromtracee = (uint8_t)random(); + uint8_t lookup_me_totracee = 0; + const uint8_t magic_totracee = (uint8_t)random(); + struct ptrace_io_desc io_fromtracee = { + .piod_op = PIOD_READ_D, + .piod_offs = &lookup_me_fromtracee, + .piod_addr = &lookup_me_fromtracee, + .piod_len = sizeof(lookup_me_fromtracee) + }; + struct ptrace_io_desc io_totracee = { + .piod_op = PIOD_WRITE_D, + .piod_offs = &lookup_me_totracee, + .piod_addr = &lookup_me_totracee, + .piod_len = sizeof(lookup_me_totracee) + }; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + lookup_me_fromtracee = magic_fromtracee; + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + lookup_me_totracee = magic_totracee; + + printf("Write lookup_me_totracee to PID=%d by tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io_totracee, 0) != -1); + + ATF_REQUIRE_EQ_MSG(lookup_me_totracee, magic_totracee, + "got value %" PRIx8 " != expected %" PRIx8, lookup_me_totracee, + magic_totracee); + + printf("Read lookup_me_fromtracee PID=%d by tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io_fromtracee, 0) != -1); + + ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee, + "got value %" PRIx8 " != expected %" PRIx8, lookup_me_fromtracee, + magic_fromtracee); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(read_d_write_d_handshake1); +ATF_TC_HEAD(read_d_write_d_handshake1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_READ_D with PT_WRITE_D handshake"); +} + +ATF_TC_BODY(read_d_write_d_handshake1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + int lookup_me_fromtracee = 0; + const int magic_fromtracee = (int)random(); + int lookup_me_totracee = 0; + const int magic_totracee = (int)random(); +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + lookup_me_fromtracee = magic_fromtracee; + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read new lookup_me_fromtracee PID=%d by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me_fromtracee = + ptrace(PT_READ_D, child, &lookup_me_fromtracee, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee, + "got value %#x != expected %#x", lookup_me_fromtracee, + magic_fromtracee); + + printf("Write new lookup_me_totracee to PID=%d from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE + (ptrace(PT_WRITE_D, child, &lookup_me_totracee, magic_totracee) + != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(read_d_write_d_handshake2); +ATF_TC_HEAD(read_d_write_d_handshake2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_WRITE_D with PT_READ_D handshake"); +} + +ATF_TC_BODY(read_d_write_d_handshake2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + int lookup_me_fromtracee = 0; + const int magic_fromtracee = (int)random(); + int lookup_me_totracee = 0; + const int magic_totracee = (int)random(); +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + lookup_me_fromtracee = magic_fromtracee; + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Write new lookup_me_totracee to PID=%d from tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE + (ptrace(PT_WRITE_D, child, &lookup_me_totracee, magic_totracee) + != -1); + + printf("Read new lookup_me_fromtracee PID=%d by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me_fromtracee = + ptrace(PT_READ_D, child, &lookup_me_fromtracee, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee, + "got value %#x != expected %#x", lookup_me_fromtracee, + magic_fromtracee); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +/* These dummy functions are used to be copied with ptrace(2) calls */ +static int __used +dummy_fn1(int a, int b, int c, int d) +{ + + a *= 1; + b += 2; + c -= 3; + d /= 4; + + return a + b * c - d; +} + +static int __used +dummy_fn2(int a, int b, int c, int d) +{ + + a *= 4; + b += 3; + c -= 2; + d /= 1; + + return a + b * c - d; +} + +static int __used +dummy_fn3(int a, int b, int c, int d) +{ + + a *= 10; + b += 20; + c -= 30; + d /= 40; + + return a + b * c - d; +} + +static int __used +dummy_fn4(int a, int b, int c, int d) +{ + + a *= 40; + b += 30; + c -= 20; + d /= 10; + + return a + b * c - d; +} + +ATF_TC(io_read_i1); +ATF_TC_HEAD(io_read_i1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_IO with PIOD_READ_I and len = sizeof(uint8_t)"); +} + +ATF_TC_BODY(io_read_i1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + uint8_t lookup_me = 0; + uint8_t magic; + memcpy(&magic, dummy_fn1, sizeof(magic)); + struct ptrace_io_desc io = { + .piod_op = PIOD_READ_I, + .piod_offs = dummy_fn1, + .piod_addr = &lookup_me, + .piod_len = sizeof(lookup_me) + }; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); + + ATF_REQUIRE_EQ_MSG(lookup_me, magic, + "got value %" PRIx8 " != expected %" PRIx8, lookup_me, magic); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(io_read_i2); +ATF_TC_HEAD(io_read_i2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_IO with PIOD_READ_I and len = sizeof(uint16_t)"); +} + +ATF_TC_BODY(io_read_i2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + uint16_t lookup_me = 0; + uint16_t magic; + memcpy(&magic, dummy_fn1, sizeof(magic)); + struct ptrace_io_desc io = { + .piod_op = PIOD_READ_I, + .piod_offs = dummy_fn1, + .piod_addr = &lookup_me, + .piod_len = sizeof(lookup_me) + }; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); + + ATF_REQUIRE_EQ_MSG(lookup_me, magic, + "got value %" PRIx16 " != expected %" PRIx16, lookup_me, magic); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(io_read_i3); +ATF_TC_HEAD(io_read_i3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_IO with PIOD_READ_I and len = sizeof(uint32_t)"); +} + +ATF_TC_BODY(io_read_i3, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + uint32_t lookup_me = 0; + uint32_t magic; + memcpy(&magic, dummy_fn1, sizeof(magic)); + struct ptrace_io_desc io = { + .piod_op = PIOD_READ_I, + .piod_offs = dummy_fn1, + .piod_addr = &lookup_me, + .piod_len = sizeof(lookup_me) + }; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); + + ATF_REQUIRE_EQ_MSG(lookup_me, magic, + "got value %" PRIx32 " != expected %" PRIx32, lookup_me, magic); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(io_read_i4); +ATF_TC_HEAD(io_read_i4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_IO with PIOD_READ_I and len = sizeof(uint64_t)"); +} + +ATF_TC_BODY(io_read_i4, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + uint64_t lookup_me = 0; + uint64_t magic; + memcpy(&magic, dummy_fn1, sizeof(magic)); + struct ptrace_io_desc io = { + .piod_op = PIOD_READ_I, + .piod_offs = dummy_fn1, + .piod_addr = &lookup_me, + .piod_len = sizeof(lookup_me) + }; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1); + + ATF_REQUIRE_EQ_MSG(lookup_me, magic, + "got value %" PRIx64 " != expected %" PRIx64, lookup_me, magic); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(read_i1); +ATF_TC_HEAD(read_i1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_READ_I called once"); +} + +ATF_TC_BODY(read_i1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + int lookup_me = 0; + int magic; + memcpy(&magic, dummy_fn1, sizeof(magic)); +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read new lookup_me from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me = ptrace(PT_READ_I, child, dummy_fn1, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me, magic, + "got value %#x != expected %#x", lookup_me, magic); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(read_i2); +ATF_TC_HEAD(read_i2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_READ_I called twice"); +} + +ATF_TC_BODY(read_i2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + int lookup_me1 = 0; + int lookup_me2 = 0; + int magic1; + int magic2; + memcpy(&magic1, dummy_fn1, sizeof(magic1)); + memcpy(&magic2, dummy_fn2, sizeof(magic2)); +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me1 = ptrace(PT_READ_I, child, dummy_fn1, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me1, magic1, + "got value %#x != expected %#x", lookup_me1, magic1); + + printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me2 = ptrace(PT_READ_I, child, dummy_fn2, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me2, magic2, + "got value %#x != expected %#x", lookup_me2, magic2); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(read_i3); +ATF_TC_HEAD(read_i3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_READ_I called three times"); +} + +ATF_TC_BODY(read_i3, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + int lookup_me1 = 0; + int lookup_me2 = 0; + int lookup_me3 = 0; + int magic1; + int magic2; + int magic3; + memcpy(&magic1, dummy_fn1, sizeof(magic1)); + memcpy(&magic2, dummy_fn2, sizeof(magic2)); + memcpy(&magic3, dummy_fn3, sizeof(magic3)); +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me1 = ptrace(PT_READ_I, child, dummy_fn1, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me1, magic1, + "got value %#x != expected %#x", lookup_me1, magic1); + + printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me2 = ptrace(PT_READ_I, child, dummy_fn2, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me2, magic2, + "got value %#x != expected %#x", lookup_me2, magic2); + + printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me3 = ptrace(PT_READ_I, child, dummy_fn3, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me3, magic3, + "got value %#x != expected %#x", lookup_me3, magic3); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(read_i4); +ATF_TC_HEAD(read_i4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_READ_I called four times"); +} + +ATF_TC_BODY(read_i4, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; + int lookup_me1 = 0; + int lookup_me2 = 0; + int lookup_me3 = 0; + int lookup_me4 = 0; + int magic1; + int magic2; + int magic3; + int magic4; + memcpy(&magic1, dummy_fn1, sizeof(magic1)); + memcpy(&magic2, dummy_fn2, sizeof(magic2)); + memcpy(&magic3, dummy_fn3, sizeof(magic3)); + memcpy(&magic4, dummy_fn4, sizeof(magic4)); +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me1 = ptrace(PT_READ_I, child, dummy_fn1, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me1, magic1, + "got value %#x != expected %#x", lookup_me1, magic1); + + printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me2 = ptrace(PT_READ_I, child, dummy_fn2, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me2, magic2, + "got value %#x != expected %#x", lookup_me2, magic2); + + printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me3 = ptrace(PT_READ_I, child, dummy_fn3, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me3, magic3, + "got value %#x != expected %#x", lookup_me3, magic3); + + printf("Read new lookup_me4 from tracee (PID=%d) by tracer (PID=%d)\n", + child, getpid()); + errno = 0; + lookup_me4 = ptrace(PT_READ_I, child, dummy_fn4, 0); + ATF_REQUIRE_EQ(errno, 0); + + ATF_REQUIRE_EQ_MSG(lookup_me4, magic4, + "got value %#x != expected %#x", lookup_me4, magic4); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +#if defined(HAVE_GPREGS) +ATF_TC(regs1); +ATF_TC_HEAD(regs1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify plain PT_GETREGS call without further steps"); +} + +ATF_TC_BODY(regs1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + struct reg r; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Call GETREGS for the child process\n"); + ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(HAVE_GPREGS) +ATF_TC(regs2); +ATF_TC_HEAD(regs2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify plain PT_GETREGS call and retrieve PC"); +} + +ATF_TC_BODY(regs2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + struct reg r; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Call GETREGS for the child process\n"); + ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1); + + printf("Retrieved PC=%" PRIxREGISTER "\n", PTRACE_REG_PC(&r)); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(HAVE_GPREGS) +ATF_TC(regs3); +ATF_TC_HEAD(regs3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify plain PT_GETREGS call and retrieve SP"); +} + +ATF_TC_BODY(regs3, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + struct reg r; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Call GETREGS for the child process\n"); + ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1); + + printf("Retrieved SP=%" PRIxREGISTER "\n", PTRACE_REG_SP(&r)); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(HAVE_GPREGS) +ATF_TC(regs4); +ATF_TC_HEAD(regs4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify plain PT_GETREGS call and retrieve INTRV"); +} + +ATF_TC_BODY(regs4, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + struct reg r; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Call GETREGS for the child process\n"); + ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1); + + printf("Retrieved INTRV=%" PRIxREGISTER "\n", PTRACE_REG_INTRV(&r)); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(HAVE_GPREGS) +ATF_TC(regs5); +ATF_TC_HEAD(regs5, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_GETREGS and PT_SETREGS calls without changing regs"); +} + +ATF_TC_BODY(regs5, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + struct reg r; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Call GETREGS for the child process\n"); + ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1); + + printf("Call SETREGS for the child process (without changed regs)\n"); + ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(HAVE_FPREGS) +ATF_TC(fpregs1); +ATF_TC_HEAD(fpregs1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify plain PT_GETFPREGS call without further steps"); +} + +ATF_TC_BODY(fpregs1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + struct fpreg r; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Call GETFPREGS for the child process\n"); + ATF_REQUIRE(ptrace(PT_GETFPREGS, child, &r, 0) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(HAVE_FPREGS) +ATF_TC(fpregs2); +ATF_TC_HEAD(fpregs2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_GETFPREGS and PT_SETFPREGS calls without changing " + "regs"); +} + +ATF_TC_BODY(fpregs2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + struct fpreg r; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Call GETFPREGS for the child process\n"); + ATF_REQUIRE(ptrace(PT_GETFPREGS, child, &r, 0) != -1); + + printf("Call SETFPREGS for the child (without changed regs)\n"); + ATF_REQUIRE(ptrace(PT_SETFPREGS, child, &r, 0) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(PT_STEP) +ATF_TC(step1); +ATF_TC_HEAD(step1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify single PT_STEP call"); +} + +ATF_TC_BODY(step1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + int happy; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + happy = check_happy(100); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(happy, check_happy(100)); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Before resuming the child process where it left off and " + "without signal to be sent (use PT_STEP)\n"); + ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(PT_STEP) +ATF_TC(step2); +ATF_TC_HEAD(step2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_STEP called twice"); +} + +ATF_TC_BODY(step2, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + int happy; + int N = 2; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + happy = check_happy(999); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(happy, check_happy(999)); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + while (N --> 0) { + printf("Before resuming the child process where it left off " + "and without signal to be sent (use PT_STEP)\n"); + ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), + child); + + validate_status_stopped(status, SIGTRAP); + } + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(PT_STEP) +ATF_TC(step3); +ATF_TC_HEAD(step3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_STEP called three times"); +} + +ATF_TC_BODY(step3, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + int happy; + int N = 3; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + happy = check_happy(999); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(happy, check_happy(999)); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + while (N --> 0) { + printf("Before resuming the child process where it left off " + "and without signal to be sent (use PT_STEP)\n"); + ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), + child); + + validate_status_stopped(status, SIGTRAP); + } + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(PT_STEP) +ATF_TC(step4); +ATF_TC_HEAD(step4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify PT_STEP called four times"); +} + +ATF_TC_BODY(step4, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + int happy; + int N = 4; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + happy = check_happy(999); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(happy, check_happy(999)); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + while (N --> 0) { + printf("Before resuming the child process where it left off " + "and without signal to be sent (use PT_STEP)\n"); + ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), + child); + + validate_status_stopped(status, SIGTRAP); + } + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +ATF_TC(kill1); +ATF_TC_HEAD(kill1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that PT_CONTINUE with SIGKILL terminates child"); +} + +ATF_TC_BODY(kill1, tc) +{ + const int sigval = SIGSTOP, sigsent = SIGKILL; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + /* NOTREACHED */ + FORKEE_ASSERTX(0 && + "Child should be terminated by a signal from its parent"); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigsent) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_signaled(status, sigsent, 0); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(kill2); +ATF_TC_HEAD(kill2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that PT_KILL terminates child"); +} + +ATF_TC_BODY(kill2, tc) +{ + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + /* NOTREACHED */ + FORKEE_ASSERTX(0 && + "Child should be terminated by a signal from its parent"); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_KILL, child, (void*)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_signaled(status, SIGKILL, 0); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(lwpinfo1); +ATF_TC_HEAD(lwpinfo1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify basic LWPINFO call for single thread (PT_TRACE_ME)"); +} + +ATF_TC_BODY(lwpinfo1, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + struct ptrace_lwpinfo info = {0, 0}; + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Before calling ptrace(2) with PT_LWPINFO for child\n"); + ATF_REQUIRE(ptrace(PT_LWPINFO, child, &info, sizeof(info)) != -1); + + printf("Assert that there exists a thread\n"); + ATF_REQUIRE(info.pl_lwpid > 0); + + printf("Assert that lwp thread %d received event PL_EVENT_SIGNAL\n", + info.pl_lwpid); + ATF_REQUIRE_EQ_MSG(info.pl_event, PL_EVENT_SIGNAL, + "Received event %d != expected event %d", + info.pl_event, PL_EVENT_SIGNAL); + + printf("Before calling ptrace(2) with PT_LWPINFO for child\n"); + ATF_REQUIRE(ptrace(PT_LWPINFO, child, &info, sizeof(info)) != -1); + + printf("Assert that there are no more lwp threads in child\n"); + ATF_REQUIRE_EQ(info.pl_lwpid, 0); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +#if defined(TWAIT_HAVE_PID) +ATF_TC(lwpinfo2); +ATF_TC_HEAD(lwpinfo2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify basic LWPINFO call for single thread (PT_ATTACH from " + "tracer)"); +} + +ATF_TC_BODY(lwpinfo2, tc) +{ + struct msg_fds parent_tracee, parent_tracer; + const int exitval_tracee = 5; + const int exitval_tracer = 10; + pid_t tracee, tracer, wpid; + uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + struct ptrace_lwpinfo info = {0, 0}; + + printf("Spawn tracee\n"); + ATF_REQUIRE(msg_open(&parent_tracee) == 0); + ATF_REQUIRE(msg_open(&parent_tracer) == 0); + tracee = atf_utils_fork(); + if (tracee == 0) { + + /* Wait for message from the parent */ + CHILD_TO_PARENT("tracee ready", parent_tracee, msg); + CHILD_FROM_PARENT("tracee exit", parent_tracee, msg); + + _exit(exitval_tracee); + } + PARENT_FROM_CHILD("tracee ready", parent_tracee, msg); + + printf("Spawn debugger\n"); + tracer = atf_utils_fork(); + if (tracer == 0) { + /* No IPC to communicate with the child */ + printf("Before calling PT_ATTACH from tracee %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1); + + /* Wait for tracee and assert that it was stopped w/ SIGSTOP */ + FORKEE_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); + + forkee_status_stopped(status, SIGSTOP); + + printf("Before calling ptrace(2) with PT_LWPINFO for child\n"); + FORKEE_ASSERT(ptrace(PT_LWPINFO, tracee, &info, sizeof(info)) + != -1); + + printf("Assert that there exists a thread\n"); + FORKEE_ASSERTX(info.pl_lwpid > 0); + + printf("Assert that lwp thread %d received event " + "PL_EVENT_SIGNAL\n", info.pl_lwpid); + FORKEE_ASSERT_EQ(info.pl_event, PL_EVENT_SIGNAL); + + printf("Before calling ptrace(2) with PT_LWPINFO for child\n"); + FORKEE_ASSERT(ptrace(PT_LWPINFO, tracee, &info, sizeof(info)) + != -1); + + printf("Assert that there are no more lwp threads in child\n"); + FORKEE_ASSERTX(info.pl_lwpid == 0); + + /* Resume tracee with PT_CONTINUE */ + FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1); + + /* Inform parent that tracer has attached to tracee */ + CHILD_TO_PARENT("tracer ready", parent_tracer, msg); + /* Wait for parent */ + CHILD_FROM_PARENT("tracer wait", parent_tracer, msg); + + /* Wait for tracee and assert that it exited */ + FORKEE_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, 0), tracee); + + forkee_status_exited(status, exitval_tracee); + + printf("Before exiting of the tracer process\n"); + _exit(exitval_tracer); + } + + printf("Wait for the tracer to attach to the tracee\n"); + PARENT_FROM_CHILD("tracer ready", parent_tracer, msg); + + printf("Resume the tracee and let it exit\n"); + PARENT_TO_CHILD("tracee exit", parent_tracee, msg); + + printf("Detect that tracee is zombie\n"); + await_zombie(tracee); + + printf("Assert that there is no status about tracee - " + "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS( + wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0); + + printf("Resume the tracer and let it detect exited tracee\n"); + PARENT_TO_CHILD("tracer wait", parent_tracer, msg); + + printf("Wait for tracer to finish its job and exit - calling %s()\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0), + tracer); + + validate_status_exited(status, exitval_tracer); + + printf("Wait for tracee to finish its job and exit - calling %s()\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), + tracee); + + validate_status_exited(status, exitval_tracee); + + msg_close(&parent_tracer); + msg_close(&parent_tracee); +} +#endif + +ATF_TC(siginfo1); +ATF_TC_HEAD(siginfo1, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify basic PT_GET_SIGINFO call for SIGTRAP from tracee"); +} + +ATF_TC_BODY(siginfo1, tc) +{ + const int exitval = 5; + const int sigval = SIGTRAP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + struct ptrace_siginfo info; + memset(&info, 0, sizeof(info)); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); + ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); + + printf("Signal traced to lwpid=%d\n", info.psi_lwpid); + printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n", + info.psi_siginfo.si_signo, info.psi_siginfo.si_code, + info.psi_siginfo.si_errno); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(siginfo2); +ATF_TC_HEAD(siginfo2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify basic PT_GET_SIGINFO and PT_SET_SIGINFO calls without " + "modification of SIGINT from tracee"); +} + +static int siginfo2_caught = 0; + +static void +siginfo2_sighandler(int sig) +{ + FORKEE_ASSERT_EQ(sig, SIGINT); + + ++siginfo2_caught; +} + +ATF_TC_BODY(siginfo2, tc) +{ + const int exitval = 5; + const int sigval = SIGINT; + pid_t child, wpid; + struct sigaction sa; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + struct ptrace_siginfo info; + memset(&info, 0, sizeof(info)); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + sa.sa_handler = siginfo2_sighandler; + sa.sa_flags = SA_SIGINFO; + sigemptyset(&sa.sa_mask); + + FORKEE_ASSERT(sigaction(sigval, &sa, NULL) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(siginfo2_caught, 1); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); + ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); + + printf("Signal traced to lwpid=%d\n", info.psi_lwpid); + printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n", + info.psi_siginfo.si_signo, info.psi_siginfo.si_code, + info.psi_siginfo.si_errno); + + printf("Before calling ptrace(2) with PT_SET_SIGINFO for child\n"); + ATF_REQUIRE(ptrace(PT_SET_SIGINFO, child, &info, sizeof(info)) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigval) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(siginfo3); +ATF_TC_HEAD(siginfo3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify basic PT_GET_SIGINFO and PT_SET_SIGINFO calls with " + "setting signal to new value"); +} + +static int siginfo3_caught = 0; + +static void +siginfo3_sigaction(int sig, siginfo_t *info, void *ctx) +{ + FORKEE_ASSERT_EQ(sig, SIGTRAP); + + FORKEE_ASSERT_EQ(info->si_signo, SIGTRAP); + FORKEE_ASSERT_EQ(info->si_code, TRAP_BRKPT); + + ++siginfo3_caught; +} + +ATF_TC_BODY(siginfo3, tc) +{ + const int exitval = 5; + const int sigval = SIGINT; + const int sigfaked = SIGTRAP; + const int sicodefaked = TRAP_BRKPT; + pid_t child, wpid; + struct sigaction sa; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + struct ptrace_siginfo info; + memset(&info, 0, sizeof(info)); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + sa.sa_sigaction = siginfo3_sigaction; + sa.sa_flags = SA_SIGINFO; + sigemptyset(&sa.sa_mask); + + FORKEE_ASSERT(sigaction(sigfaked, &sa, NULL) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(siginfo3_caught, 1); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); + ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); + + printf("Signal traced to lwpid=%d\n", info.psi_lwpid); + printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n", + info.psi_siginfo.si_signo, info.psi_siginfo.si_code, + info.psi_siginfo.si_errno); + + printf("Before setting new faked signal to signo=%d si_code=%d\n", + sigfaked, sicodefaked); + info.psi_siginfo.si_signo = sigfaked; + info.psi_siginfo.si_code = sicodefaked; + + printf("Before calling ptrace(2) with PT_SET_SIGINFO for child\n"); + ATF_REQUIRE(ptrace(PT_SET_SIGINFO, child, &info, sizeof(info)) != -1); + + printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); + ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); + + printf("Before checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigfaked); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, sicodefaked); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigfaked) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +ATF_TC(siginfo4); +ATF_TC_HEAD(siginfo4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Detect SIGTRAP TRAP_EXEC from tracee"); +} + +ATF_TC_BODY(siginfo4, tc) +{ + const int sigval = SIGTRAP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + + struct ptrace_siginfo info; + memset(&info, 0, sizeof(info)); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before calling execve(2) from child\n"); + execlp("/bin/echo", "/bin/echo", NULL); + + FORKEE_ASSERT(0 && "Not reached"); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); + ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); + + printf("Signal traced to lwpid=%d\n", info.psi_lwpid); + printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n", + info.psi_siginfo.si_signo, info.psi_siginfo.si_code, + info.psi_siginfo.si_errno); + + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_EXEC); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} + +#if defined(TWAIT_HAVE_PID) +ATF_TC(siginfo5); +ATF_TC_HEAD(siginfo5, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify that fork(2) is intercepted by ptrace(2) with EVENT_MASK " + "set to PTRACE_FORK and reports correct signal information"); +} + +ATF_TC_BODY(siginfo5, tc) +{ + const int exitval = 5; + const int exitval2 = 15; + const int sigval = SIGSTOP; + pid_t child, child2, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + ptrace_state_t state; + const int slen = sizeof(state); + ptrace_event_t event; + const int elen = sizeof(event); + struct ptrace_siginfo info; + + memset(&info, 0, sizeof(info)); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT((child2 = fork()) != 1); + + if (child2 == 0) + _exit(exitval2); + + FORKEE_REQUIRE_SUCCESS + (wpid = TWAIT_GENERIC(child2, &status, 0), child2); + + forkee_status_exited(status, exitval2); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); + ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); + + printf("Before checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP); + + printf("Enable PTRACE_FORK in EVENT_MASK for the child %d\n", child); + event.pe_set_event = PTRACE_FORK; + ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); + ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); + + printf("Before checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_CHLD); + + ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1); + ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK); + + child2 = state.pe_other_pid; + printf("Reported PTRACE_FORK event with forkee %d\n", child2); + + printf("Before calling %s() for the forkee %d of the child %d\n", + TWAIT_FNAME, child2, child); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0), + child2); + + validate_status_stopped(status, SIGTRAP); + + printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); + ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); + + printf("Before checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_CHLD); + + ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child2, &state, slen) != -1); + ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK); + ATF_REQUIRE_EQ(state.pe_other_pid, child); + + printf("Before resuming the forkee process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child2, (void *)1, 0) != -1); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the forkee - expected exited\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0), + child2); + + validate_status_exited(status, exitval2); + + printf("Before calling %s() for the forkee - expected no process\n", + TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, + wpid = TWAIT_GENERIC(child2, &status, 0)); + + printf("Before calling %s() for the child - expected stopped " + "SIGCHLD\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGCHLD); + + printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); + ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); + + printf("Before checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGCHLD); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, CLD_EXITED); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child - expected exited\n", + TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child - expected no process\n", + TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +#if defined(PT_STEP) +ATF_TC(siginfo6); +ATF_TC_HEAD(siginfo6, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify single PT_STEP call with signal information check"); +} + +ATF_TC_BODY(siginfo6, tc) +{ + const int exitval = 5; + const int sigval = SIGSTOP; + pid_t child, wpid; +#if defined(TWAIT_HAVE_STATUS) + int status; +#endif + int happy; + struct ptrace_siginfo info; + + memset(&info, 0, sizeof(info)); + + printf("Before forking process PID=%d\n", getpid()); + ATF_REQUIRE((child = fork()) != -1); + if (child == 0) { + printf("Before calling PT_TRACE_ME from child %d\n", getpid()); + FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1); + + happy = check_happy(100); + + printf("Before raising %s from child\n", strsignal(sigval)); + FORKEE_ASSERT(raise(sigval) == 0); + + FORKEE_ASSERT_EQ(happy, check_happy(100)); + + printf("Before exiting of the child process\n"); + _exit(exitval); + } + printf("Parent process PID=%d, child's PID=%d\n", getpid(), child); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, sigval); + + printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); + ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); + + printf("Before checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP); + + printf("Before resuming the child process where it left off and " + "without signal to be sent (use PT_STEP)\n"); + ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_stopped(status, SIGTRAP); + + printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); + ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1); + + printf("Before checking siginfo_t\n"); + ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP); + ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_TRACE); + + printf("Before resuming the child process where it left off and " + "without signal to be sent\n"); + ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child); + + validate_status_exited(status, exitval); + + printf("Before calling %s() for the child\n", TWAIT_FNAME); + TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0)); +} +#endif + +ATF_TP_ADD_TCS(tp) +{ + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); + ATF_TP_ADD_TC(tp, traceme1); + ATF_TP_ADD_TC(tp, traceme2); + ATF_TP_ADD_TC(tp, traceme3); + ATF_TP_ADD_TC(tp, traceme4); + + ATF_TP_ADD_TC_HAVE_PID(tp, attach1); + ATF_TP_ADD_TC_HAVE_PID(tp, attach2); + ATF_TP_ADD_TC(tp, attach3); + ATF_TP_ADD_TC(tp, attach4); + ATF_TP_ADD_TC_HAVE_PID(tp, attach5); + ATF_TP_ADD_TC_HAVE_PID(tp, attach6); + ATF_TP_ADD_TC_HAVE_PID(tp, attach7); + + ATF_TP_ADD_TC(tp, eventmask1); + ATF_TP_ADD_TC(tp, eventmask2); + + ATF_TP_ADD_TC_HAVE_PID(tp, fork1); + ATF_TP_ADD_TC(tp, fork2); + + ATF_TP_ADD_TC_HAVE_PID(tp, vfork1); + ATF_TP_ADD_TC(tp, vfork2); + + ATF_TP_ADD_TC(tp, io_read_d1); + ATF_TP_ADD_TC(tp, io_read_d2); + ATF_TP_ADD_TC(tp, io_read_d3); + ATF_TP_ADD_TC(tp, io_read_d4); + + ATF_TP_ADD_TC(tp, io_write_d1); + ATF_TP_ADD_TC(tp, io_write_d2); + ATF_TP_ADD_TC(tp, io_write_d3); + ATF_TP_ADD_TC(tp, io_write_d4); + + ATF_TP_ADD_TC(tp, read_d1); + ATF_TP_ADD_TC(tp, read_d2); + ATF_TP_ADD_TC(tp, read_d3); + ATF_TP_ADD_TC(tp, read_d4); + + ATF_TP_ADD_TC(tp, write_d1); + ATF_TP_ADD_TC(tp, write_d2); + ATF_TP_ADD_TC(tp, write_d3); + ATF_TP_ADD_TC(tp, write_d4); + + ATF_TP_ADD_TC(tp, io_read_d_write_d_handshake1); + ATF_TP_ADD_TC(tp, io_read_d_write_d_handshake2); + + ATF_TP_ADD_TC(tp, read_d_write_d_handshake1); + ATF_TP_ADD_TC(tp, read_d_write_d_handshake2); + + ATF_TP_ADD_TC(tp, io_read_i1); + ATF_TP_ADD_TC(tp, io_read_i2); + ATF_TP_ADD_TC(tp, io_read_i3); + ATF_TP_ADD_TC(tp, io_read_i4); + + ATF_TP_ADD_TC(tp, read_i1); + ATF_TP_ADD_TC(tp, read_i2); + ATF_TP_ADD_TC(tp, read_i3); + ATF_TP_ADD_TC(tp, read_i4); + + ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs1); + ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs2); + ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs3); + ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs4); + ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs5); + + ATF_TP_ADD_TC_HAVE_FPREGS(tp, fpregs1); + ATF_TP_ADD_TC_HAVE_FPREGS(tp, fpregs2); + + ATF_TP_ADD_TC_PT_STEP(tp, step1); + ATF_TP_ADD_TC_PT_STEP(tp, step2); + ATF_TP_ADD_TC_PT_STEP(tp, step3); + ATF_TP_ADD_TC_PT_STEP(tp, step4); + + ATF_TP_ADD_TC(tp, kill1); + ATF_TP_ADD_TC(tp, kill2); + + ATF_TP_ADD_TC(tp, lwpinfo1); + ATF_TP_ADD_TC_HAVE_PID(tp, lwpinfo2); + + ATF_TP_ADD_TC(tp, siginfo1); + ATF_TP_ADD_TC(tp, siginfo2); + ATF_TP_ADD_TC(tp, siginfo3); + ATF_TP_ADD_TC(tp, siginfo4); + ATF_TP_ADD_TC_HAVE_PID(tp, siginfo5); + ATF_TP_ADD_TC_PT_STEP(tp, siginfo6); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/kernel/t_ptrace_wait.h b/contrib/netbsd-tests/kernel/t_ptrace_wait.h new file mode 100644 index 0000000..9c6921c --- /dev/null +++ b/contrib/netbsd-tests/kernel/t_ptrace_wait.h @@ -0,0 +1,431 @@ +/* $NetBSD: t_ptrace_wait.h,v 1.7 2017/01/09 22:09:20 kamil Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +/* Detect plain wait(2) use-case */ +#if !defined(TWAIT_WAITPID) && \ + !defined(TWAIT_WAITID) && \ + !defined(TWAIT_WAIT3) && \ + !defined(TWAIT_WAIT4) && \ + !defined(TWAIT_WAIT6) +#define TWAIT_WAIT +#endif + +/* + * There are two classes of wait(2)-like functions: + * - wait4(2)-like accepting pid_t, optional options parameter, struct rusage* + * - wait6(2)-like accepting idtype_t, id_t, struct wrusage, mandatory options + * + * The TWAIT_FNAME value is to be used for convenience in debug messages. + * + * The TWAIT_GENERIC() macro is designed to reuse the same unmodified + * code with as many wait(2)-like functions as possible. + * + * In a common use-case wait4(2) and wait6(2)-like function can work the almost + * the same way, however there are few important differences: + * wait6(2) must specify P_PID for idtype to match wpid from wait4(2). + * To behave like wait4(2), wait6(2) the 'options' to wait must include + * WEXITED|WTRUNCATED. + * + * There are two helper macros (they purpose it to mach more than one + * wait(2)-like function): + * The TWAIT_HAVE_STATUS - specifies whether a function can retrieve + * status (as integer value). + * The TWAIT_HAVE_PID - specifies whether a function can request + * exact process identifier + * The TWAIT_HAVE_RUSAGE - specifies whether a function can request + * the struct rusage value + * + */ + +#if defined(TWAIT_WAIT) +# define TWAIT_FNAME "wait" +# define TWAIT_WAIT4TYPE(a,b,c,d) wait((b)) +# define TWAIT_GENERIC(a,b,c) wait((b)) +# define TWAIT_HAVE_STATUS 1 +#elif defined(TWAIT_WAITPID) +# define TWAIT_FNAME "waitpid" +# define TWAIT_WAIT4TYPE(a,b,c,d) waitpid((a),(b),(c)) +# define TWAIT_GENERIC(a,b,c) waitpid((a),(b),(c)) +# define TWAIT_HAVE_PID 1 +# define TWAIT_HAVE_STATUS 1 +#elif defined(TWAIT_WAITID) +# define TWAIT_FNAME "waitid" +# define TWAIT_GENERIC(a,b,c) \ + waitid(P_PID,(a),NULL,(c)|WEXITED|WTRAPPED) +# define TWAIT_WAIT6TYPE(a,b,c,d,e,f) waitid((a),(b),(f),(d)) +# define TWAIT_HAVE_PID 1 +#elif defined(TWAIT_WAIT3) +# define TWAIT_FNAME "wait3" +# define TWAIT_WAIT4TYPE(a,b,c,d) wait3((b),(c),(d)) +# define TWAIT_GENERIC(a,b,c) wait3((b),(c),NULL) +# define TWAIT_HAVE_STATUS 1 +# define TWAIT_HAVE_RUSAGE 1 +#elif defined(TWAIT_WAIT4) +# define TWAIT_FNAME "wait4" +# define TWAIT_WAIT4TYPE(a,b,c,d) wait4((a),(b),(c),(d)) +# define TWAIT_GENERIC(a,b,c) wait4((a),(b),(c),NULL) +# define TWAIT_HAVE_PID 1 +# define TWAIT_HAVE_STATUS 1 +# define TWAIT_HAVE_RUSAGE 1 +#elif defined(TWAIT_WAIT6) +# define TWAIT_FNAME "wait6" +# define TWAIT_WAIT6TYPE(a,b,c,d,e,f) wait6((a),(b),(c),(d),(e),(f)) +# define TWAIT_GENERIC(a,b,c) \ + wait6(P_PID,(a),(b),(c)|WEXITED|WTRAPPED,NULL,NULL) +# define TWAIT_HAVE_PID 1 +# define TWAIT_HAVE_STATUS 1 +#endif + +/* + * There are 3 groups of tests: + * - TWAIT_GENERIC() (wait, wait2, waitpid, wait3, wait4, wait6) + * - TWAIT_WAIT4TYPE() (wait2, waitpid, wait3, wait4) + * - TWAIT_WAIT6TYPE() (waitid, wait6) + * + * Tests only in the above categories are allowed. However some tests are not + * possible in the context requested functionality to be verified, therefore + * there are helper macros: + * - TWAIT_HAVE_PID (wait2, waitpid, waitid, wait4, wait6) + * - TWAIT_HAVE_STATUS (wait, wait2, waitpid, wait3, wait4, wait6) + * - TWAIT_HAVE_RUSAGE (wait3, wait4) + * - TWAIT_HAVE_RETPID (wait, wait2, waitpid, wait3, wait4, wait6) + * + * If there is an intention to test e.g. wait6(2) specific features in the + * ptrace(2) context, find the most matching group and with #ifdefs reduce + * functionality of less featured than wait6(2) interface (TWAIT_WAIT6TYPE). + * + * For clarity never use negative preprocessor checks, like: + * #if !defined(TWAIT_WAIT4) + * always refer to checks for positive values. + */ + +#define TEST_REQUIRE_EQ(x, y) \ +do { \ + uintmax_t vx = (x); \ + uintmax_t vy = (y); \ + int ret = vx == vy; \ + if (!ret) \ + ATF_REQUIRE_EQ_MSG(vx, vy, "%s(%ju) == %s(%ju)", \ + #x, vx, #y, vy); \ +} while (/*CONSTCOND*/0) + +/* + * A child process cannot call atf functions and expect them to magically + * work like in the parent. + * The printf(3) messaging from a child will not work out of the box as well + * without estabilishing a communication protocol with its parent. To not + * overcomplicate the tests - do not log from a child and use err(3)/errx(3) + * wrapped with FORKEE_ASSERT()/FORKEE_ASSERTX() as that is guaranteed to work. + */ +#define FORKEE_ASSERT_EQ(x, y) \ +do { \ + uintmax_t vx = (x); \ + uintmax_t vy = (y); \ + int ret = vx == vy; \ + if (!ret) \ + errx(EXIT_FAILURE, "%s:%d %s(): Assertion failed for: " \ + "%s(%ju) == %s(%ju)", __FILE__, __LINE__, __func__, \ + #x, vx, #y, vy); \ +} while (/*CONSTCOND*/0) + +#define FORKEE_ASSERTX(x) \ +do { \ + int ret = (x); \ + if (!ret) \ + errx(EXIT_FAILURE, "%s:%d %s(): Assertion failed for: %s",\ + __FILE__, __LINE__, __func__, #x); \ +} while (/*CONSTCOND*/0) + +#define FORKEE_ASSERT(x) \ +do { \ + int ret = (x); \ + if (!ret) \ + err(EXIT_FAILURE, "%s:%d %s(): Assertion failed for: %s",\ + __FILE__, __LINE__, __func__, #x); \ +} while (/*CONSTCOND*/0) + +/* + * Simplify logic for functions using general purpose registers add HAVE_GPREGS + * + * For platforms that do not implement all needed calls for simplicity assume + * that they are unsupported at all. + */ +#if defined(PT_GETREGS) \ + && defined(PT_SETREGS) \ + && defined(PTRACE_REG_PC) \ + && defined(PTRACE_REG_SET_PC) \ + && defined(PTRACE_REG_SP) \ + && defined(PTRACE_REG_INTRV) +#define HAVE_GPREGS +#endif + +/* Add guards for floating point registers */ +#if defined(PT_GETFPREGS) \ + && defined(PT_SETFPREGS) +#define HAVE_FPREGS +#endif + +/* Add guards for cpu debug registers */ +#if defined(PT_GETDBREGS) \ + && defined(PT_SETDBREGS) +#define HAVE_DBREGS +#endif + +/* + * If waitid(2) returns because one or more processes have a state change to + * report, 0 is returned. If an error is detected, a value of -1 is returned + * and errno is set to indicate the error. If WNOHANG is specified and there + * are no stopped, continued or exited children, 0 is returned. + */ +#if defined(TWAIT_WAITID) +#define TWAIT_REQUIRE_SUCCESS(a,b) TEST_REQUIRE_EQ((a), 0) +#define TWAIT_REQUIRE_FAILURE(a,b) ATF_REQUIRE_ERRNO((a),(b) == -1) +#define FORKEE_REQUIRE_SUCCESS(a,b) FORKEE_ASSERT_EQ(a, 0) +#define FORKEE_REQUIRE_FAILURE(a,b) \ + FORKEE_ASSERTX(((a) == errno) && ((b) == -1)) +#else +#define TWAIT_REQUIRE_SUCCESS(a,b) TEST_REQUIRE_EQ((a), (b)) +#define TWAIT_REQUIRE_FAILURE(a,b) ATF_REQUIRE_ERRNO((a),(b) == -1) +#define FORKEE_REQUIRE_SUCCESS(a,b) FORKEE_ASSERT_EQ(a, b) +#define FORKEE_REQUIRE_FAILURE(a,b) \ + FORKEE_ASSERTX(((a) == errno) && ((b) == -1)) +#endif + +/* + * Helper tools to verify whether status reports exited value + */ +#if TWAIT_HAVE_STATUS +static void __used +validate_status_exited(int status, int expected) +{ + ATF_REQUIRE_MSG(WIFEXITED(status), "Reported !exited process"); + ATF_REQUIRE_MSG(!WIFCONTINUED(status), "Reported continued process"); + ATF_REQUIRE_MSG(!WIFSIGNALED(status), "Reported signaled process"); + ATF_REQUIRE_MSG(!WIFSTOPPED(status), "Reported stopped process"); + + ATF_REQUIRE_EQ_MSG(WEXITSTATUS(status), expected, + "The process has exited with invalid value %d != %d", + WEXITSTATUS(status), expected); +} + +static void __used +forkee_status_exited(int status, int expected) +{ + FORKEE_ASSERTX(WIFEXITED(status)); + FORKEE_ASSERTX(!WIFCONTINUED(status)); + FORKEE_ASSERTX(!WIFSIGNALED(status)); + FORKEE_ASSERTX(!WIFSTOPPED(status)); + + FORKEE_ASSERT_EQ(WEXITSTATUS(status), expected); +} + +static void __used +validate_status_continued(int status) +{ + ATF_REQUIRE_MSG(!WIFEXITED(status), "Reported exited process"); + ATF_REQUIRE_MSG(WIFCONTINUED(status), "Reported !continued process"); + ATF_REQUIRE_MSG(!WIFSIGNALED(status), "Reported signaled process"); + ATF_REQUIRE_MSG(!WIFSTOPPED(status), "Reported stopped process"); +} + +static void __used +forkee_status_continued(int status) +{ + FORKEE_ASSERTX(!WIFEXITED(status)); + FORKEE_ASSERTX(WIFCONTINUED(status)); + FORKEE_ASSERTX(!WIFSIGNALED(status)); + FORKEE_ASSERTX(!WIFSTOPPED(status)); +} + +static void __used +validate_status_signaled(int status, int expected_termsig, int expected_core) +{ + ATF_REQUIRE_MSG(!WIFEXITED(status), "Reported exited process"); + ATF_REQUIRE_MSG(!WIFCONTINUED(status), "Reported continued process"); + ATF_REQUIRE_MSG(WIFSIGNALED(status), "Reported !signaled process"); + ATF_REQUIRE_MSG(!WIFSTOPPED(status), "Reported stopped process"); + + ATF_REQUIRE_EQ_MSG(WTERMSIG(status), expected_termsig, + "Unexpected signal received"); + + ATF_REQUIRE_EQ_MSG(WCOREDUMP(status), expected_core, + "Unexpectedly core file %s generated", expected_core ? "not" : ""); +} + +static void __used +forkee_status_signaled(int status, int expected_termsig, int expected_core) +{ + FORKEE_ASSERTX(!WIFEXITED(status)); + FORKEE_ASSERTX(!WIFCONTINUED(status)); + FORKEE_ASSERTX(WIFSIGNALED(status)); + FORKEE_ASSERTX(!WIFSTOPPED(status)); + + FORKEE_ASSERT_EQ(WTERMSIG(status), expected_termsig); + FORKEE_ASSERT_EQ(WCOREDUMP(status), expected_core); +} + +static void __used +validate_status_stopped(int status, int expected) +{ + ATF_REQUIRE_MSG(!WIFEXITED(status), "Reported exited process"); + ATF_REQUIRE_MSG(!WIFCONTINUED(status), "Reported continued process"); + ATF_REQUIRE_MSG(!WIFSIGNALED(status), "Reported signaled process"); + ATF_REQUIRE_MSG(WIFSTOPPED(status), "Reported !stopped process"); + + char st[128], ex[128]; + strlcpy(st, strsignal(WSTOPSIG(status)), sizeof(st)); + strlcpy(ex, strsignal(expected), sizeof(ex)); + + ATF_REQUIRE_EQ_MSG(WSTOPSIG(status), expected, + "Unexpected stop signal received [%s] != [%s]", st, ex); +} + +static void __used +forkee_status_stopped(int status, int expected) +{ + FORKEE_ASSERTX(!WIFEXITED(status)); + FORKEE_ASSERTX(!WIFCONTINUED(status)); + FORKEE_ASSERTX(!WIFSIGNALED(status)); + FORKEE_ASSERTX(WIFSTOPPED(status)); + + FORKEE_ASSERT_EQ(WSTOPSIG(status), expected); +} +#else +#define validate_status_exited(a,b) +#define forkee_status_exited(a,b) +#define validate_status_continued(a,b) +#define forkee_status_continued(a,b) +#define validate_status_signaled(a,b,c) +#define forkee_status_signaled(a,b,c) +#define validate_status_stopped(a,b) +#define forkee_status_stopped(a,b) +#endif + +/* This function is currently designed to be run in the main/parent process */ +static void __used +await_zombie(pid_t process) +{ + struct kinfo_proc2 p; + size_t len = sizeof(p); + + const int name[] = { + [0] = CTL_KERN, + [1] = KERN_PROC2, + [2] = KERN_PROC_PID, + [3] = process, + [4] = sizeof(p), + [5] = 1 + }; + + const size_t namelen = __arraycount(name); + + /* Await the process becoming a zombie */ + while(1) { + ATF_REQUIRE(sysctl(name, namelen, &p, &len, NULL, 0) == 0); + + if (p.p_stat == LSZOMB) + break; + + ATF_REQUIRE(usleep(1000) == 0); + } +} + +/* Happy number sequence -- this function is used to just consume cpu cycles */ +#define HAPPY_NUMBER 1 + +/* If n is not happy then its sequence ends in the cycle: + * 4, 16, 37, 58, 89, 145, 42, 20, 4, ... */ +#define SAD_NUMBER 4 + +/* Calculate the sum of the squares of the digits of n */ +static unsigned __used +dsum(unsigned n) +{ + unsigned sum, x; + for (sum = 0; n; n /= 10) { + x = n % 10; + sum += x * x; + } + return sum; +} + +/* + * XXX: Disabled optimization is required to make tests for hardware assisted + * traps in .text functional + * + * Tested with GCC 5.4 on NetBSD 7.99.47 amd64 + */ +static int __used +#ifdef __clang__ +__attribute__((__optnone__)) +#else +__attribute__((__optimize__("O0"))) +#endif +check_happy(unsigned n) +{ + for (;;) { + unsigned total = dsum(n); + + if (total == HAPPY_NUMBER) + return 1; + if (total == SAD_NUMBER) + return 0; + + n = total; + } +} + +#if defined(TWAIT_HAVE_PID) +#define ATF_TP_ADD_TC_HAVE_PID(a,b) ATF_TP_ADD_TC(a,b) +#else +#define ATF_TP_ADD_TC_HAVE_PID(a,b) +#endif + +#if defined(HAVE_GPREGS) +#define ATF_TP_ADD_TC_HAVE_GPREGS(a,b) ATF_TP_ADD_TC(a,b) +#else +#define ATF_TP_ADD_TC_HAVE_GPREGS(a,b) +#endif + +#if defined(HAVE_FPREGS) +#define ATF_TP_ADD_TC_HAVE_FPREGS(a,b) ATF_TP_ADD_TC(a,b) +#else +#define ATF_TP_ADD_TC_HAVE_FPREGS(a,b) +#endif + +#if defined(PT_STEP) +#define ATF_TP_ADD_TC_PT_STEP(a,b) ATF_TP_ADD_TC(a,b) +#else +#define ATF_TP_ADD_TC_PT_STEP(a,b) +#endif + +#if defined(__HAVE_PTRACE_WATCHPOINTS) +#define ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(a,b) ATF_TP_ADD_TC(a,b) +#else +#define ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(a,b) +#endif diff --git a/contrib/netbsd-tests/kernel/t_ptrace_wait3.c b/contrib/netbsd-tests/kernel/t_ptrace_wait3.c new file mode 100644 index 0000000..c136431 --- /dev/null +++ b/contrib/netbsd-tests/kernel/t_ptrace_wait3.c @@ -0,0 +1,30 @@ +/* $NetBSD: t_ptrace_wait3.c,v 1.1 2016/11/07 21:09:03 kamil Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#define TWAIT_WAIT3 +#include "t_ptrace_wait.c" diff --git a/contrib/netbsd-tests/kernel/t_ptrace_wait4.c b/contrib/netbsd-tests/kernel/t_ptrace_wait4.c new file mode 100644 index 0000000..7ae771b --- /dev/null +++ b/contrib/netbsd-tests/kernel/t_ptrace_wait4.c @@ -0,0 +1,30 @@ +/* $NetBSD: t_ptrace_wait4.c,v 1.1 2016/11/07 21:09:03 kamil Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#define TWAIT_WAIT4 +#include "t_ptrace_wait.c" diff --git a/contrib/netbsd-tests/kernel/t_ptrace_wait6.c b/contrib/netbsd-tests/kernel/t_ptrace_wait6.c new file mode 100644 index 0000000..122cb1d --- /dev/null +++ b/contrib/netbsd-tests/kernel/t_ptrace_wait6.c @@ -0,0 +1,30 @@ +/* $NetBSD: t_ptrace_wait6.c,v 1.1 2016/11/07 21:09:03 kamil Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#define TWAIT_WAIT6 +#include "t_ptrace_wait.c" diff --git a/contrib/netbsd-tests/kernel/t_ptrace_waitid.c b/contrib/netbsd-tests/kernel/t_ptrace_waitid.c new file mode 100644 index 0000000..1c09be7 --- /dev/null +++ b/contrib/netbsd-tests/kernel/t_ptrace_waitid.c @@ -0,0 +1,30 @@ +/* $NetBSD: t_ptrace_waitid.c,v 1.1 2016/11/07 21:09:03 kamil Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#define TWAIT_WAITID +#include "t_ptrace_wait.c" diff --git a/contrib/netbsd-tests/kernel/t_ptrace_waitpid.c b/contrib/netbsd-tests/kernel/t_ptrace_waitpid.c new file mode 100644 index 0000000..c8f107d --- /dev/null +++ b/contrib/netbsd-tests/kernel/t_ptrace_waitpid.c @@ -0,0 +1,30 @@ +/* $NetBSD: t_ptrace_waitpid.c,v 1.1 2016/11/07 21:09:03 kamil Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#define TWAIT_WAITPID +#include "t_ptrace_wait.c" diff --git a/contrib/netbsd-tests/lib/libc/arch/sparc64/exec_prot_support.c b/contrib/netbsd-tests/lib/libc/arch/sparc64/exec_prot_support.c index 474cfc7..8ca38b4 100644 --- a/contrib/netbsd-tests/lib/libc/arch/sparc64/exec_prot_support.c +++ b/contrib/netbsd-tests/lib/libc/arch/sparc64/exec_prot_support.c @@ -1,4 +1,4 @@ -/* $NetBSD: exec_prot_support.c,v 1.1 2011/07/18 23:16:10 jym Exp $ */ +/* $NetBSD: exec_prot_support.c,v 1.2 2016/12/31 11:51:20 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -30,12 +30,13 @@ */ #include -__RCSID("$NetBSD: exec_prot_support.c,v 1.1 2011/07/18 23:16:10 jym Exp $"); +__RCSID("$NetBSD: exec_prot_support.c,v 1.2 2016/12/31 11:51:20 martin Exp $"); #include "../../common/exec_prot.h" int exec_prot_support(void) { - return NOTIMPL; + + return PERPAGE_XP; } diff --git a/contrib/netbsd-tests/lib/libc/arch/sparc64/return_one.S b/contrib/netbsd-tests/lib/libc/arch/sparc64/return_one.S index 3495260..ec8bcdd 100644 --- a/contrib/netbsd-tests/lib/libc/arch/sparc64/return_one.S +++ b/contrib/netbsd-tests/lib/libc/arch/sparc64/return_one.S @@ -1,8 +1,11 @@ -/* $NetBSD: return_one.S,v 1.1 2011/07/18 23:16:10 jym Exp $ */ +/* $NetBSD: return_one.S,v 1.2 2016/12/31 11:51:20 martin Exp $ */ #include -.globl return_one, return_one_end; +.global return_one_end -return_one: return_one_end: - nop +ENTRY(return_one) +return_one: + retl + mov 1, %o0 +return_one_end: diff --git a/contrib/netbsd-tests/lib/libc/c063/t_faccessat.c b/contrib/netbsd-tests/lib/libc/c063/t_faccessat.c index 99235ea..7de4f61 100644 --- a/contrib/netbsd-tests/lib/libc/c063/t_faccessat.c +++ b/contrib/netbsd-tests/lib/libc/c063/t_faccessat.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_faccessat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $ */ +/* $NetBSD: t_faccessat.c,v 1.3 2017/01/10 15:13:56 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,8 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_faccessat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $"); +__RCSID("$NetBSD: t_faccessat.c,v 1.3 2017/01/10 15:13:56 christos Exp $"); +#include +#include #include #include #include @@ -39,10 +41,6 @@ __RCSID("$NetBSD: t_faccessat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $"); #include #include #include -#include -#ifdef __FreeBSD__ -#include -#endif #define DIR "dir" #define FILE "dir/faccessat" diff --git a/contrib/netbsd-tests/lib/libc/c063/t_fchmodat.c b/contrib/netbsd-tests/lib/libc/c063/t_fchmodat.c index 6598059..a7bb683 100644 --- a/contrib/netbsd-tests/lib/libc/c063/t_fchmodat.c +++ b/contrib/netbsd-tests/lib/libc/c063/t_fchmodat.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_fchmodat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $ */ +/* $NetBSD: t_fchmodat.c,v 1.3 2017/01/10 15:13:56 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,8 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fchmodat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $"); +__RCSID("$NetBSD: t_fchmodat.c,v 1.3 2017/01/10 15:13:56 christos Exp $"); +#include +#include #include #include #include @@ -39,10 +41,6 @@ __RCSID("$NetBSD: t_fchmodat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $"); #include #include #include -#include -#ifdef __FreeBSD__ -#include -#endif #define DIR "dir" #define FILE "dir/fchmodat" diff --git a/contrib/netbsd-tests/lib/libc/c063/t_fchownat.c b/contrib/netbsd-tests/lib/libc/c063/t_fchownat.c index 2ca14cf..631d55a 100644 --- a/contrib/netbsd-tests/lib/libc/c063/t_fchownat.c +++ b/contrib/netbsd-tests/lib/libc/c063/t_fchownat.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_fchownat.c,v 1.3 2013/03/17 04:46:06 jmmv Exp $ */ +/* $NetBSD: t_fchownat.c,v 1.4 2017/01/10 15:13:56 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,8 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fchownat.c,v 1.3 2013/03/17 04:46:06 jmmv Exp $"); +__RCSID("$NetBSD: t_fchownat.c,v 1.4 2017/01/10 15:13:56 christos Exp $"); +#include +#include #include #include #include @@ -40,10 +42,6 @@ __RCSID("$NetBSD: t_fchownat.c,v 1.3 2013/03/17 04:46:06 jmmv Exp $"); #include #include #include -#include -#ifdef __FreeBSD__ -#include -#endif #define DIR "dir" #define FILE "dir/fchownat" diff --git a/contrib/netbsd-tests/lib/libc/c063/t_fexecve.c b/contrib/netbsd-tests/lib/libc/c063/t_fexecve.c index 30b26a7..b9aa017 100644 --- a/contrib/netbsd-tests/lib/libc/c063/t_fexecve.c +++ b/contrib/netbsd-tests/lib/libc/c063/t_fexecve.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_fexecve.c,v 1.2 2013/03/17 04:35:59 jmmv Exp $ */ +/* $NetBSD: t_fexecve.c,v 1.3 2017/01/10 15:15:09 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fexecve.c,v 1.2 2013/03/17 04:35:59 jmmv Exp $"); +__RCSID("$NetBSD: t_fexecve.c,v 1.3 2017/01/10 15:15:09 christos Exp $"); #include @@ -70,9 +70,7 @@ ATF_TC_BODY(fexecve, tc) error = 76; else error = EXIT_FAILURE; -#ifdef __FreeBSD__ (void)close(fd); -#endif err(error, "fexecve"); } } diff --git a/contrib/netbsd-tests/lib/libc/c063/t_fstatat.c b/contrib/netbsd-tests/lib/libc/c063/t_fstatat.c index b23f625..c17961f 100644 --- a/contrib/netbsd-tests/lib/libc/c063/t_fstatat.c +++ b/contrib/netbsd-tests/lib/libc/c063/t_fstatat.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_fstatat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $ */ +/* $NetBSD: t_fstatat.c,v 1.3 2017/01/10 15:13:56 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,8 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fstatat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $"); +__RCSID("$NetBSD: t_fstatat.c,v 1.3 2017/01/10 15:13:56 christos Exp $"); +#include +#include #include #include #include @@ -39,10 +41,6 @@ __RCSID("$NetBSD: t_fstatat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $"); #include #include #include -#include -#ifdef __FreeBSD__ -#include -#endif #define DIR "dir" #define FILE "dir/fstatat" diff --git a/contrib/netbsd-tests/lib/libc/c063/t_mkfifoat.c b/contrib/netbsd-tests/lib/libc/c063/t_mkfifoat.c index 3736dfa..5c496c8 100644 --- a/contrib/netbsd-tests/lib/libc/c063/t_mkfifoat.c +++ b/contrib/netbsd-tests/lib/libc/c063/t_mkfifoat.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_mkfifoat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $ */ +/* $NetBSD: t_mkfifoat.c,v 1.3 2017/01/10 15:15:09 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_mkfifoat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $"); +__RCSID("$NetBSD: t_mkfifoat.c,v 1.3 2017/01/10 15:15:09 christos Exp $"); #include #include @@ -63,9 +63,7 @@ ATF_TC_BODY(mkfifoat_fd, tc) ATF_REQUIRE((fd = mkfifoat(dfd, BASEFIFO, mode)) != -1); ATF_REQUIRE(close(fd) == 0); ATF_REQUIRE(access(FIFO, F_OK) == 0); -#ifdef __FreeBSD__ (void)close(dfd); -#endif } ATF_TC(mkfifoat_fdcwd); diff --git a/contrib/netbsd-tests/lib/libc/c063/t_mknodat.c b/contrib/netbsd-tests/lib/libc/c063/t_mknodat.c index e8f71cd..7c3ab9b 100644 --- a/contrib/netbsd-tests/lib/libc/c063/t_mknodat.c +++ b/contrib/netbsd-tests/lib/libc/c063/t_mknodat.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_mknodat.c,v 1.3 2013/03/17 04:46:06 jmmv Exp $ */ +/* $NetBSD: t_mknodat.c,v 1.4 2017/01/10 15:15:09 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_mknodat.c,v 1.3 2013/03/17 04:46:06 jmmv Exp $"); +__RCSID("$NetBSD: t_mknodat.c,v 1.4 2017/01/10 15:15:09 christos Exp $"); #include #include @@ -80,9 +80,7 @@ ATF_TC_BODY(mknodat_fd, tc) ATF_REQUIRE((fd = mknodat(dfd, BASEFILE, mode, dev)) != -1); ATF_REQUIRE(close(fd) == 0); ATF_REQUIRE(access(FILE, F_OK) == 0); -#ifdef __FreeBSD__ (void)close(dfd); -#endif } ATF_TC(mknodat_fdcwd); diff --git a/contrib/netbsd-tests/lib/libc/c063/t_o_search.c b/contrib/netbsd-tests/lib/libc/c063/t_o_search.c index d9dbe19..7cefa8b 100644 --- a/contrib/netbsd-tests/lib/libc/c063/t_o_search.c +++ b/contrib/netbsd-tests/lib/libc/c063/t_o_search.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_o_search.c,v 1.4 2013/03/17 04:46:06 jmmv Exp $ */ +/* $NetBSD: t_o_search.c,v 1.5 2017/01/10 22:25:01 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,9 +29,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_o_search.c,v 1.4 2013/03/17 04:46:06 jmmv Exp $"); +__RCSID("$NetBSD: t_o_search.c,v 1.5 2017/01/10 22:25:01 christos Exp $"); #include + +#include +#include + #include #include #include @@ -40,7 +44,6 @@ __RCSID("$NetBSD: t_o_search.c,v 1.4 2013/03/17 04:46:06 jmmv Exp $"); #include #include #include -#include /* * dholland 20130112: disable tests that require O_SEARCH semantics diff --git a/contrib/netbsd-tests/lib/libc/c063/t_openat.c b/contrib/netbsd-tests/lib/libc/c063/t_openat.c index 5112efc..f7c8c74 100644 --- a/contrib/netbsd-tests/lib/libc/c063/t_openat.c +++ b/contrib/netbsd-tests/lib/libc/c063/t_openat.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_openat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $ */ +/* $NetBSD: t_openat.c,v 1.3 2017/01/10 15:13:56 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,8 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_openat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $"); +__RCSID("$NetBSD: t_openat.c,v 1.3 2017/01/10 15:13:56 christos Exp $"); +#include +#include #include #include #include @@ -39,10 +41,6 @@ __RCSID("$NetBSD: t_openat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $"); #include #include #include -#include -#ifdef __FreeBSD__ -#include -#endif #define DIR "dir" #define FILE "dir/openat" diff --git a/contrib/netbsd-tests/lib/libc/c063/t_readlinkat.c b/contrib/netbsd-tests/lib/libc/c063/t_readlinkat.c index c9bc267..cf14652 100644 --- a/contrib/netbsd-tests/lib/libc/c063/t_readlinkat.c +++ b/contrib/netbsd-tests/lib/libc/c063/t_readlinkat.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_readlinkat.c,v 1.3 2013/03/17 04:46:06 jmmv Exp $ */ +/* $NetBSD: t_readlinkat.c,v 1.4 2017/01/10 15:13:56 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,8 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_readlinkat.c,v 1.3 2013/03/17 04:46:06 jmmv Exp $"); +__RCSID("$NetBSD: t_readlinkat.c,v 1.4 2017/01/10 15:13:56 christos Exp $"); +#include +#include #include #include #include @@ -39,10 +41,6 @@ __RCSID("$NetBSD: t_readlinkat.c,v 1.3 2013/03/17 04:46:06 jmmv Exp $"); #include #include #include -#include -#ifdef __FreeBSD__ -#include -#endif #define DIR "dir" #define FILE "dir/readlinkat" diff --git a/contrib/netbsd-tests/lib/libc/c063/t_unlinkat.c b/contrib/netbsd-tests/lib/libc/c063/t_unlinkat.c index 220c4b2..9897b92 100644 --- a/contrib/netbsd-tests/lib/libc/c063/t_unlinkat.c +++ b/contrib/netbsd-tests/lib/libc/c063/t_unlinkat.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_unlinkat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $ */ +/* $NetBSD: t_unlinkat.c,v 1.3 2017/01/10 15:13:56 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,8 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_unlinkat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $"); +__RCSID("$NetBSD: t_unlinkat.c,v 1.3 2017/01/10 15:13:56 christos Exp $"); +#include +#include #include #include #include @@ -39,10 +41,6 @@ __RCSID("$NetBSD: t_unlinkat.c,v 1.2 2013/03/17 04:46:06 jmmv Exp $"); #include #include #include -#include -#ifdef __FreeBSD__ -#include -#endif #define DIR "dir" #define FILE "dir/unlinkat" diff --git a/contrib/netbsd-tests/lib/libc/c063/t_utimensat.c b/contrib/netbsd-tests/lib/libc/c063/t_utimensat.c index bbfa28b..682c2df 100644 --- a/contrib/netbsd-tests/lib/libc/c063/t_utimensat.c +++ b/contrib/netbsd-tests/lib/libc/c063/t_utimensat.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_utimensat.c,v 1.5 2013/03/17 04:46:06 jmmv Exp $ */ +/* $NetBSD: t_utimensat.c,v 1.6 2017/01/10 15:13:56 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,8 +29,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_utimensat.c,v 1.5 2013/03/17 04:46:06 jmmv Exp $"); +__RCSID("$NetBSD: t_utimensat.c,v 1.6 2017/01/10 15:13:56 christos Exp $"); +#include +#include +#include #include #include #include @@ -39,11 +42,6 @@ __RCSID("$NetBSD: t_utimensat.c,v 1.5 2013/03/17 04:46:06 jmmv Exp $"); #include #include #include -#include -#ifdef __FreeBSD__ -#include -#endif -#include #define DIR "dir" #define FILE "dir/utimensat" diff --git a/contrib/netbsd-tests/lib/libc/db/h_db.c b/contrib/netbsd-tests/lib/libc/db/h_db.c index dfb1385..dd19a03 100644 --- a/contrib/netbsd-tests/lib/libc/db/h_db.c +++ b/contrib/netbsd-tests/lib/libc/db/h_db.c @@ -1,4 +1,4 @@ -/* $NetBSD: h_db.c,v 1.1 2011/01/07 15:05:58 pgoyette Exp $ */ +/* $NetBSD: h_db.c,v 1.3 2016/09/24 21:18:22 christos Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\ #if 0 static char sccsid[] = "@(#)dbtest.c 8.17 (Berkeley) 9/1/94"; #else -__RCSID("$NetBSD: h_db.c,v 1.1 2011/01/07 15:05:58 pgoyette Exp $"); +__RCSID("$NetBSD: h_db.c,v 1.3 2016/09/24 21:18:22 christos Exp $"); #endif #endif /* not lint */ @@ -57,12 +57,13 @@ __RCSID("$NetBSD: h_db.c,v 1.1 2011/01/07 15:05:58 pgoyette Exp $"); #include #include #include +#include "btree.h" enum S { COMMAND, COMPARE, GET, PUT, REMOVE, SEQ, SEQFLAG, KEY, DATA }; static void compare(DBT *, DBT *); static DBTYPE dbtype(const char *); -static void dump(DB *, int); +static void dump(DB *, int, int); static void get(DB *, DBT *); static void getdata(DB *, DBT *, DBT *); static void put(DB *, DBT *, DBT *); @@ -73,6 +74,9 @@ static void *rfile(char *, size_t *); static void seq(DB *, DBT *); static u_int setflags(char *); static void *setinfo(DBTYPE, char *); +#ifdef __NetBSD__ +static void unlinkpg(DB *); +#endif static void usage(void) __attribute__((__noreturn__)); static void *xcopy(void *, size_t); static void chkcmd(enum S); @@ -82,6 +86,9 @@ static void chkkey(enum S); #ifdef STATISTICS extern void __bt_stat(DB *); #endif +#ifdef __NetBSD__ +extern int __bt_relink(BTREE *, PAGE *); +#endif static DBTYPE type; /* Database type. */ static void *infop; /* Iflags. */ @@ -315,8 +322,16 @@ lkey: switch (command) { } break; case 'o': - dump(dbp, p[1] == 'r'); + dump(dbp, p[1] == 'r', 0); + break; +#ifdef __NetBSD__ + case 'O': + dump(dbp, p[1] == 'r', 1); break; + case 'u': + unlinkpg(dbp); + break; +#endif default: errx(1, "line %zu: %s: unknown command character", lineno, p); @@ -483,17 +498,25 @@ seq(DB *dbp, DBT *kp) } static void -dump(DB *dbp, int rev) +dump(DB *dbp, int rev, int recurse) { DBT key, data; int xflags, nflags; if (rev) { xflags = R_LAST; +#ifdef __NetBSD__ + nflags = recurse ? R_RPREV : R_PREV; +#else nflags = R_PREV; +#endif } else { xflags = R_FIRST; +#ifdef __NetBSD__ + nflags = recurse ? R_RNEXT : R_NEXT; +#else nflags = R_NEXT; +#endif } for (;; xflags = nflags) switch (dbp->seq(dbp, &key, &data, xflags)) { @@ -511,6 +534,42 @@ dump(DB *dbp, int rev) done: return; } +#ifdef __NetBSD__ +void +unlinkpg(DB *dbp) +{ + BTREE *t = dbp->internal; + PAGE *h = NULL; + pgno_t pg; + + for (pg = P_ROOT; pg < t->bt_mp->npages; + mpool_put(t->bt_mp, h, 0), pg++) { + if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) + break; + /* Look for a nonempty leaf page that has both left + * and right siblings. */ + if (h->prevpg == P_INVALID || h->nextpg == P_INVALID) + continue; + if (NEXTINDEX(h) == 0) + continue; + if ((h->flags & (P_BLEAF | P_RLEAF))) + break; + } + if (h == NULL || pg == t->bt_mp->npages) { + errx(1, "%s: no appropriate page found", __func__); + return; + } + if (__bt_relink(t, h) != 0) { + perror("unlinkpg"); + goto cleanup; + } + h->prevpg = P_INVALID; + h->nextpg = P_INVALID; +cleanup: + mpool_put(t->bt_mp, h, MPOOL_DIRTY); +} +#endif + static u_int setflags(char *s) { @@ -725,7 +784,11 @@ static void usage(void) { (void)fprintf(stderr, - "Usage: %s [-l] [-f file] [-i info] [-o file] type script\n", - getprogname()); +#ifdef __NetBSD__ + "Usage: %s [-lu] [-f file] [-i info] [-o file] [-O file] " +#else + "Usage: %s [-l] [-f file] [-i info] [-o file] " +#endif + "type script\n", getprogname()); exit(1); } diff --git a/contrib/netbsd-tests/lib/libc/db/t_db.sh b/contrib/netbsd-tests/lib/libc/db/t_db.sh index eb6b8c9..6858e36 100755 --- a/contrib/netbsd-tests/lib/libc/db/t_db.sh +++ b/contrib/netbsd-tests/lib/libc/db/t_db.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_db.sh,v 1.6 2015/11/18 18:35:35 christos Exp $ +# $NetBSD: t_db.sh,v 1.7 2016/09/24 20:12:33 christos Exp $ # # Copyright (c) 2008 The NetBSD Foundation, Inc. # All rights reserved. @@ -563,6 +563,7 @@ delete_recno_body() h_repeated() { + local type="$1" TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} @@ -581,7 +582,7 @@ h_repeated() } }' >in - $(prog_db) btree in + $(prog_db) $type in } atf_test_case repeated_btree @@ -641,11 +642,10 @@ duplicate_btree_body() h_cursor_flags() { + local type=$1 TMPDIR="$(pwd)/db_dir"; export TMPDIR mkdir ${TMPDIR} - type=$1 - echo $SEVEN_SEVEN | awk '{ for (i = 1; i <= 20; ++i) @@ -784,6 +784,7 @@ h_byte_orders() echo p echo k$i echo d$i + echo S echo g echo k$i done >in @@ -974,6 +975,298 @@ bsize_torture_body() done } +atf_test_case btree_weird_page_split +btree_weird_page_split_head() +{ + atf_set "descr" \ + "Test for a weird page split condition where an insertion " \ + "into index 0 of a page that would cause the new item to " \ + "be the only item on the left page results in index 0 of " \ + "the right page being erroneously skipped; this only " \ + "happens with one particular key+data length for each page size." +} +btree_weird_page_split_body() +{ + for psize in 512 1024 2048 4096 8192; do + echo " page size $psize" + kdsizes=`awk 'BEGIN { + psize = '$psize'; hsize = int(psize/2); + for (kdsize = hsize-40; kdsize <= hsize; kdsize++) { + print kdsize; + } + }' /dev/null` + + # Use a series of keylen+datalen values in the right + # neighborhood to find the one that triggers the bug. + # We could compute the exact size that triggers the + # bug but this additional fuzz may be useful. + + # Insert keys in reverse order to maximize the chances + # for a split on index 0. + + for kdsize in $kdsizes; do + awk 'BEGIN { + kdsize = '$kdsize'; + for (i = 8; i-- > 0; ) { + s = sprintf("a%03d:%09d", i, kdsize); + for (j = 0; j < kdsize-20; j++) { + s = s "x"; + } + printf("p\nka%03d\nd%s\n", i, s); + } + print "o"; + }' /dev/null > in + sed -n 's/^d//p' in | sort > exp + atf_check -o file:exp \ + "$(prog_db)" -i psize=$psize btree in + done + done +} + +# Extremely tricky test attempting to replicate some unusual database +# corruption seen in the field: pieces of the database becoming +# inaccessible to random access, sequential access, or both. The +# hypothesis is that at least some of these are triggered by the bug +# in page splits on index 0 with a particular exact keylen+datalen. +# (See Test 40.) For psize=4096, this size is exactly 2024. + +# The order of operations here relies on very specific knowledge of +# the internals of the btree access method in order to place records +# at specific offsets in a page and to create certain keys on internal +# pages. The to-be-split page immediately prior to the bug-triggering +# split has the following properties: +# +# * is not the leftmost leaf page +# * key on the parent page is compares less than the key of the item +# on index 0 +# * triggering record's key also compares greater than the key on the +# parent page + +# Additionally, we prime the mpool LRU chain so that the head page on +# the chain has the following properties: +# +# * record at index 0 is located where it will not get overwritten by +# items written to the right-hand page during the split +# * key of the record at index 0 compares less than the key of the +# bug-triggering record + +# If the page-split bug exists, this test appears to create a database +# where some records are inaccessible to a search, but still remain in +# the file and are accessible by sequential traversal. At least one +# record gets duplicated out of sequence. + +atf_test_case btree_tricky_page_split +btree_tricky_page_split_head() +{ + atf_set "descr" \ + "btree: no unsearchables due to page split on index 0" +} +btree_tricky_page_split_body() +{ + list=`(for i in a b c d; do + for j in 990 998 999; do + echo g ${i}${j} 1024 + done + done; + echo g y997 2014 + for i in y z; do + for j in 998 999; do + echo g ${i}${j} 1024 + done + done)` + # Exact number for trigger condition accounts for newlines + # retained by dbtest with -ofile but not without; we use + # -ofile, so count newlines. keylen=5,datalen=5+2014 for + # psize=4096 here. + (cat - < in + (echo "$list"; echo "$list") | awk '{ + s = $2; + for (i = 0; i < $3; i++) { + s = s "x"; + } + print s; + }' > exp + atf_check -o file:exp \ + "$(prog_db)" -i psize=4096 btree in +} + +# Begin FreeBSD +if false; then +# End FreeBSD +atf_test_case btree_recursive_traversal +btree_recursive_traversal_head() +{ + atf_set "descr" \ + "btree: Test for recursive traversal successfully " \ + "retrieving records that are inaccessible to normal " \ + "sequential 'sibling-link' traversal. This works by " \ + "unlinking a few leaf pages but leaving their parent " \ + "links intact. To verify that the unlink actually makes " \ + "records inaccessible, the test first uses 'o' to do a " \ + "normal sequential traversal, followed by 'O' to do a " \ + "recursive traversal." +} +btree_recursive_traversal_body() +{ + fill="abcdefghijklmnopqrstuvwxyzy" + script='{ + for (i = 0; i < 20000; i++) { + printf("p\nkAA%05d\nd%05d%s\n", i, i, $0); + } + print "u"; + print "u"; + print "u"; + print "u"; + }' + (echo $fill | awk "$script"; echo o) > in1 + echo $fill | + awk '{ + for (i = 0; i < 20000; i++) { + if (i >= 5 && i <= 40) + continue; + printf("%05d%s\n", i, $0); + } + }' > exp1 + atf_check -o file:exp1 \ + "$(prog_db)" -i psize=512 btree in1 + echo $fill | + awk '{ + for (i = 0; i < 20000; i++) { + printf("%05d%s\n", i, $0); + } + }' > exp2 + (echo $fill | awk "$script"; echo O) > in2 + atf_check -o file:exp2 \ + "$(prog_db)" -i psize=512 btree in2 +} +# Begin FreeBSD +fi +# End FreeBSD + +atf_test_case btree_byteswap_unaligned_access_bksd +btree_byteswap_unaligned_access_bksd_head() +{ + atf_set "descr" \ + "btree: big key, small data, byteswap unaligned access" +} +btree_byteswap_unaligned_access_bksd_body() +{ + (echo foo; echo bar) | + awk '{ + s = $0 + for (i = 0; i < 488; i++) { + s = s "x"; + } + printf("p\nk%s\ndx\n", s); + }' > in + for order in 1234 4321; do + atf_check \ + "$(prog_db)" -o out -i psize=512,lorder=$order btree in + done +} + +atf_test_case btree_byteswap_unaligned_access_skbd +btree_byteswap_unaligned_access_skbd_head() +{ + atf_set "descr" \ + "btree: small key, big data, byteswap unaligned access" +} +btree_byteswap_unaligned_access_skbd_body() +{ + # 484 = 512 - 20 (header) - 7 ("foo1234") - 1 (newline) + (echo foo1234; echo bar1234) | + awk '{ + s = $0 + for (i = 0; i < 484; i++) { + s = s "x"; + } + printf("p\nk%s\nd%s\n", $0, s); + }' > in + for order in 1234 4321; do + atf_check \ + "$(prog_db)" -o out -i psize=512,lorder=$order btree in + done +} + +atf_test_case btree_known_byte_order +btree_known_byte_order_head() +{ + atf_set "descr" \ + "btree: small key, big data, known byte order" +} +btree_known_byte_order_body() +{ + local a="-i psize=512,lorder=" + + (echo foo1234; echo bar1234) | + awk '{ + s = $0 + for (i = 0; i < 484; i++) { + s = s "x"; + } + printf("%s\n", s); + }' > exp + (echo foo1234; echo bar1234) | + awk '{ + s = $0 + for (i = 0; i < 484; i++) { + s = s "x"; + } + printf("p\nk%s\nd%s\n", $0, s); + }' > in1 + for order in 1234 4321; do + atf_check \ + "$(prog_db)" -f out.$order $a$order btree in1 + done + (echo g; echo kfoo1234; echo g; echo kbar1234) > in2 + for order in 1234 4321; do + atf_check -o file:exp \ + "$(prog_db)" -s -f out.$order $a$order btree in2 + done +} + atf_init_test_cases() { atf_add_test_case small_btree @@ -1002,4 +1295,16 @@ atf_init_test_cases() atf_add_test_case bsize_ffactor atf_add_test_case four_char_hash atf_add_test_case bsize_torture + atf_add_test_case btree_weird_page_split + atf_add_test_case btree_tricky_page_split + # Begin FreeBSD + if false; then + # End FreeBSD + atf_add_test_case btree_recursive_traversal + # Begin FreeBSD + fi + # End FreeBSD + atf_add_test_case btree_byteswap_unaligned_access_bksd + atf_add_test_case btree_byteswap_unaligned_access_skbd + atf_add_test_case btree_known_byte_order } diff --git a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_fileactions.c b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_fileactions.c index 5bbf337..74009a8 100644 --- a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_fileactions.c +++ b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_fileactions.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_fileactions.c,v 1.5 2012/04/09 19:42:07 martin Exp $ */ +/* $NetBSD: t_fileactions.c,v 1.6 2017/01/10 22:36:29 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -31,10 +31,11 @@ */ -#ifdef __FreeBSD__ -#include -#endif #include + +#include +#include + #include #include #include @@ -42,7 +43,6 @@ #include #include #include -#include ATF_TC(t_spawn_openmode); diff --git a/contrib/netbsd-tests/lib/libc/gen/t_assert.c b/contrib/netbsd-tests/lib/libc/gen/t_assert.c index a09c130..ce73015 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_assert.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_assert.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_assert.c,v 1.2 2011/06/14 05:28:00 jruoho Exp $ */ +/* $NetBSD: t_assert.c,v 1.3 2017/01/10 15:17:57 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,8 +29,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_assert.c,v 1.2 2011/06/14 05:28:00 jruoho Exp $"); +__RCSID("$NetBSD: t_assert.c,v 1.3 2017/01/10 15:17:57 christos Exp $"); +#include +#include +#include #include #include @@ -40,11 +43,6 @@ __RCSID("$NetBSD: t_assert.c,v 1.2 2011/06/14 05:28:00 jruoho Exp $"); #include #include -#ifdef __FreeBSD__ -#include -#include -#include - static void disable_corefile(void) { @@ -55,7 +53,6 @@ disable_corefile(void) ATF_REQUIRE(setrlimit(RLIMIT_CORE, &limits) == 0); } -#endif static void handler(int); @@ -82,9 +79,7 @@ ATF_TC_BODY(assert_false, tc) if (pid == 0) { -#ifdef __FreeBSD__ disable_corefile(); -#endif (void)closefrom(0); (void)memset(&sa, 0, sizeof(struct sigaction)); @@ -122,9 +117,7 @@ ATF_TC_BODY(assert_true, tc) if (pid == 0) { -#ifdef __FreeBSD__ disable_corefile(); -#endif (void)closefrom(0); (void)memset(&sa, 0, sizeof(struct sigaction)); diff --git a/contrib/netbsd-tests/lib/libc/gen/t_dir.c b/contrib/netbsd-tests/lib/libc/gen/t_dir.c index b37d89d..40de116 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_dir.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_dir.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_dir.c,v 1.6 2013/10/19 17:45:00 christos Exp $ */ +/* $NetBSD: t_dir.c,v 1.10 2017/01/11 18:15:02 christos Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -26,22 +26,19 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include - +#include #include +#include #include #include +#include #include #include #include #include #include -#include -#ifdef __FreeBSD__ -#include -#endif ATF_TC(seekdir_basic); ATF_TC_HEAD(seekdir_basic, tc) @@ -58,7 +55,6 @@ ATF_TC_BODY(seekdir_basic, tc) struct dirent *entry; long here; -#ifdef __FreeBSD__ #define CREAT(x, m) do { \ int _creat_fd; \ ATF_REQUIRE_MSG((_creat_fd = creat((x), (m))) != -1, \ @@ -72,12 +68,6 @@ ATF_TC_BODY(seekdir_basic, tc) CREAT("t/a", 0600); CREAT("t/b", 0600); CREAT("t/c", 0600); -#else - mkdir("t", 0755); - creat("t/a", 0600); - creat("t/b", 0600); - creat("t/c", 0600); -#endif dp = opendir("t"); if ( dp == NULL) @@ -85,35 +75,40 @@ ATF_TC_BODY(seekdir_basic, tc) /* skip two for . and .. */ entry = readdir(dp); + ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s", + ".", strerror(errno)); + entry = readdir(dp); + ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s", + "..", strerror(errno)); /* get first entry */ entry = readdir(dp); + ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s", + "first", strerror(errno)); + here = telldir(dp); -#ifdef __FreeBSD__ - ATF_REQUIRE_MSG(here != -1, - "telldir failed: %s", strerror(errno)); -#endif + ATF_REQUIRE_MSG(here != -1, "telldir failed: %s", strerror(errno)); /* get second entry */ entry = readdir(dp); -#ifdef __FreeBSD__ - ATF_REQUIRE_MSG(entry != NULL, - "readdir failed: %s", strerror(errno)); -#endif + ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s", + "second", strerror(errno)); + wasname = strdup(entry->d_name); if (wasname == NULL) atf_tc_fail("cannot allocate memory"); /* get third entry */ entry = readdir(dp); + ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s", + "third", strerror(errno)); /* try to return to the position after the first entry */ seekdir(dp, here); entry = readdir(dp); - - if (entry == NULL) - atf_tc_fail("entry 1 not found"); + ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s", + "first[1]", strerror(errno)); if (strcmp(entry->d_name, wasname) != 0) atf_tc_fail("1st seekdir found wrong name"); @@ -121,25 +116,22 @@ ATF_TC_BODY(seekdir_basic, tc) seekdir(dp, here); here = telldir(dp); entry = readdir(dp); - - if (entry == NULL) - atf_tc_fail("entry 2 not found"); + ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s", + "second[1]", strerror(errno)); if (strcmp(entry->d_name, wasname) != 0) atf_tc_fail("2nd seekdir found wrong name"); /* One more time, to make sure that telldir() doesn't affect result */ seekdir(dp, here); entry = readdir(dp); + ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s", + "third[1]", strerror(errno)); - if (entry == NULL) - atf_tc_fail("entry 3 not found"); if (strcmp(entry->d_name, wasname) != 0) atf_tc_fail("3rd seekdir found wrong name"); closedir(dp); -#ifdef __FreeBSD__ free(wasname); -#endif } ATF_TC(telldir_leak); diff --git a/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c b/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c index c0064c3..69ee8d2 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_fnmatch.c,v 1.6 2014/10/12 22:33:41 christos Exp $ */ +/* $NetBSD: t_fnmatch.c,v 1.7 2016/10/31 05:08:53 dholland Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_fnmatch.c,v 1.6 2014/10/12 22:33:41 christos Exp $"); +__RCSID("$NetBSD: t_fnmatch.c,v 1.7 2016/10/31 05:08:53 dholland Exp $"); #include #include @@ -166,6 +166,7 @@ ATF_TC_BODY(fnmatch_initialbracket, tc) ATF_CHECK(fnmatch("[!]a-]", "b", 0) == 0); ATF_CHECK(fnmatch("[]-_]", "^", 0) == 0); /* range: ']', '^', '_' */ ATF_CHECK(fnmatch("[!]-_]", "X", 0) == 0); + ATF_CHECK(fnmatch("[A-\\\\]", "[", 0) == 0); ATF_CHECK(fnmatch("[a-z]/[a-z]", "a/b", 0) == 0); ATF_CHECK(fnmatch("[*]/b", "*/b", 0) == 0); ATF_CHECK(fnmatch("[?]/b", "?/b", 0) == 0); diff --git a/contrib/netbsd-tests/lib/libc/gen/t_ftok.c b/contrib/netbsd-tests/lib/libc/gen/t_ftok.c index 718d310..4c1ab18 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_ftok.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_ftok.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_ftok.c,v 1.1 2011/11/08 05:47:00 jruoho Exp $ */ +/* $NetBSD: t_ftok.c,v 1.2 2017/01/10 15:19:52 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_ftok.c,v 1.1 2011/11/08 05:47:00 jruoho Exp $"); +__RCSID("$NetBSD: t_ftok.c,v 1.2 2017/01/10 15:19:52 christos Exp $"); #include #include @@ -68,9 +68,7 @@ ATF_TC_BODY(ftok_link, tc) fd = open(path, O_RDONLY | O_CREAT); ATF_REQUIRE(fd >= 0); -#ifdef __FreeBSD__ (void)close(fd); -#endif ATF_REQUIRE(link(path, hlnk) == 0); ATF_REQUIRE(symlink(path, slnk) == 0); diff --git a/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c b/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c index 53055d2..17eac87 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_humanize_number.c,v 1.8 2012/03/18 07:14:08 jruoho Exp $ */ +/* $NetBSD: t_humanize_number.c,v 1.9 2017/01/10 15:20:44 christos Exp $ */ /*- * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. @@ -247,9 +247,7 @@ ATF_TC_BODY(humanize_number_basic, tc) newline(); atf_tc_fail_nonfatal("Failed for table entry %d", i); } -#ifdef __FreeBSD__ free(buf); -#endif } ATF_TC(humanize_number_big); diff --git a/contrib/netbsd-tests/lib/libc/gen/t_sleep.c b/contrib/netbsd-tests/lib/libc/gen/t_sleep.c index e89df69..5e36456 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_sleep.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_sleep.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_sleep.c,v 1.9 2016/08/11 21:34:11 kre Exp $ */ +/* $NetBSD: t_sleep.c,v 1.11 2017/01/10 15:43:59 maya Exp $ */ /*- * Copyright (c) 2006 Frank Kardel @@ -26,8 +26,17 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#ifdef __FreeBSD__ +#include +#endif +#include +#include +#include +#include /* for TIMESPEC_TO_TIMEVAL on FreeBSD */ + #include #include +#include #include #include #include @@ -35,10 +44,6 @@ #include #include -#include -#include -#include - #include "isqemu.h" #define BILLION 1000000000LL /* nano-seconds per second */ @@ -49,11 +54,6 @@ #define KEVNT_TIMEOUT 10300 /* measured in milli-seconds */ #define FUZZ (40 * MILLION) /* scheduling fuzz accepted - 40 ms */ -#ifdef __FreeBSD__ -#include -#include -#endif - /* * Timer notes * diff --git a/contrib/netbsd-tests/lib/libc/gen/t_time.c b/contrib/netbsd-tests/lib/libc/gen/t_time.c index 2905403..15a8d58 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_time.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_time.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_time.c,v 1.3 2014/10/31 12:22:38 justin Exp $ */ +/* $NetBSD: t_time.c,v 1.4 2017/01/10 15:32:46 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,11 +29,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_time.c,v 1.3 2014/10/31 12:22:38 justin Exp $"); +__RCSID("$NetBSD: t_time.c,v 1.4 2017/01/10 15:32:46 christos Exp $"); -#ifdef __FreeBSD__ -#include -#endif #include #include #include @@ -41,6 +38,7 @@ __RCSID("$NetBSD: t_time.c,v 1.3 2014/10/31 12:22:38 justin Exp $"); #include #include #include +#include #include ATF_TC(time_copy); diff --git a/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c b/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c index 1c813fb..61121b8 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_ttyname.c,v 1.3 2011/05/01 18:14:01 jruoho Exp $ */ +/* $NetBSD: t_ttyname.c,v 1.4 2017/01/10 15:33:40 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_ttyname.c,v 1.3 2011/05/01 18:14:01 jruoho Exp $"); +__RCSID("$NetBSD: t_ttyname.c,v 1.4 2017/01/10 15:33:40 christos Exp $"); #include #include @@ -78,9 +78,7 @@ ATF_TC_BODY(ttyname_err, tc) ATF_REQUIRE(ttyname(fd) == NULL); ATF_REQUIRE(errno == ENOTTY); -#ifdef __FreeBSD__ (void)close(fd); -#endif } } diff --git a/contrib/netbsd-tests/lib/libc/gen/t_vis.c b/contrib/netbsd-tests/lib/libc/gen/t_vis.c index 76f85f4..adb0930 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_vis.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_vis.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_vis.c,v 1.8 2015/05/23 14:02:11 christos Exp $ */ +/* $NetBSD: t_vis.c,v 1.9 2017/01/10 15:16:57 christos Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -144,9 +144,7 @@ ATF_TC_BODY(strunvis_hex, tc) } } -/* Begin FreeBSD: ^/stable/10 doesn't have VIS_NOLOCALE */ #ifdef VIS_NOLOCALE -/* End FreeBSD */ ATF_TC(strvis_locale); ATF_TC_HEAD(strvis_locale, tc) { @@ -175,9 +173,7 @@ ATF_TC_BODY(strvis_locale, tc) setlocale(LC_CTYPE, ol); free(ol); } -/* Begin FreeBSD: ^/stable/10 doesn't have VIS_NOLOCALE */ #endif /* VIS_NOLOCALE */ -/* End FreeBSD */ ATF_TP_ADD_TCS(tp) { @@ -186,13 +182,9 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, strvis_null); ATF_TP_ADD_TC(tp, strvis_empty); ATF_TP_ADD_TC(tp, strunvis_hex); -/* Begin FreeBSD: ^/stable/10 doesn't have VIS_NOLOCALE */ #ifdef VIS_NOLOCALE -/* End FreeBSD */ ATF_TP_ADD_TC(tp, strvis_locale); -/* Begin FreeBSD: ^/stable/10 doesn't have VIS_NOLOCALE */ #endif /* VIS_NOLOCALE */ -/* End FreeBSD */ return atf_no_error(); } diff --git a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c index 0254743..9c14a22 100644 --- a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c +++ b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c @@ -1,7 +1,7 @@ -/* $NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $ */ +/* $NetBSD: t_rpc.c,v 1.10 2016/08/27 14:36:22 christos Exp $ */ #include -__RCSID("$NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $"); +__RCSID("$NetBSD: t_rpc.c,v 1.10 2016/08/27 14:36:22 christos Exp $"); #include #include @@ -21,7 +21,7 @@ __RCSID("$NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $"); #define SKIPX(ev, msg, ...) do { \ atf_tc_skip(msg, __VA_ARGS__); \ - return; \ + return ev; \ } while(/*CONSTCOND*/0) #ifdef __FreeBSD__ @@ -32,8 +32,8 @@ __RCSID("$NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $"); #endif #else -#define ERRX(ev, msg, ...) errx(ev, msg, __VA_ARGS__) -#define SKIPX(ev, msg, ...) errx(ev, msg, __VA_ARGS__) +#define ERRX(ev, msg, ...) errx(EXIT_FAILURE, msg, __VA_ARGS__) +#define SKIPX(ev, msg, ...) errx(EXIT_FAILURE, msg, __VA_ARGS__) #endif #ifdef DEBUG @@ -89,7 +89,7 @@ onehost(const char *host, const char *transp) __rpc_control(CLCR_SET_RPCB_TIMEOUT, &tv); if ((clnt = clnt_create(host, RPCBPROG, RPCBVERS, transp)) == NULL) - SKIPX(EXIT_FAILURE, "clnt_create (%s)", clnt_spcreateerror("")); + SKIPX(, "clnt_create (%s)", clnt_spcreateerror("")); tv.tv_sec = 1; tv.tv_usec = 0; @@ -101,7 +101,7 @@ onehost(const char *host, const char *transp) if (clnt_call(clnt, RPCBPROC_NULL, xdr_void, NULL, xdr_void, NULL, tv) != RPC_SUCCESS) #endif - ERRX(EXIT_FAILURE, "clnt_call (%s)", clnt_sperror(clnt, "")); + ERRX(, "clnt_call (%s)", clnt_sperror(clnt, "")); clnt_control(clnt, CLGET_SVC_ADDR, (char *) &addr); reply(NULL, &addr, NULL); } @@ -123,13 +123,13 @@ server(struct svc_req *rqstp, SVCXPRT *transp) switch (rqstp->rq_proc) { case NULLPROC: if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) - ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 0); + ERRX(, "svc_sendreply failed %d", 0); return; case PLUSONE: break; case DESTROY: if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) - ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 0); + ERRX(, "svc_sendreply failed %d", 0); svc_destroy(transp); exit(0); default: @@ -144,7 +144,7 @@ server(struct svc_req *rqstp, SVCXPRT *transp) DPRINTF("About to increment\n"); num++; if (!svc_sendreply(transp, (xdrproc_t)xdr_int, (void *)&num)) - ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 1); + ERRX(, "svc_sendreply failed %d", 1); DPRINTF("Leaving server procedure.\n"); } @@ -201,13 +201,9 @@ regtest(const char *hostname, const char *transp, const char *arg, int p) svc_fdset_init(p ? SVC_FDSET_POLL : 0); #endif if (!svc_create(server, PROGNUM, VERSNUM, transp)) -#ifdef __NetBSD__ - ERRX(EXIT_FAILURE, "Cannot create server %d", num); -#else { SKIPXI(EXIT_FAILURE, "Cannot create server %d", num); } -#endif switch ((pid = fork())) { case 0: diff --git a/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c b/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c index 905306d..06f2de0 100644 --- a/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c +++ b/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c @@ -51,10 +51,6 @@ static const char * const inf_strings[] = const char *nan_string = "NaN(x)y"; #endif -#ifdef __FreeBSD__ -#define __HAVE_LONG_DOUBLE -#endif - ATF_TC(strtod_basic); ATF_TC_HEAD(strtod_basic, tc) { diff --git a/contrib/netbsd-tests/lib/libc/string/t_memcpy.c b/contrib/netbsd-tests/lib/libc/string/t_memcpy.c index 5bbd924..64cdb29 100644 --- a/contrib/netbsd-tests/lib/libc/string/t_memcpy.c +++ b/contrib/netbsd-tests/lib/libc/string/t_memcpy.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_memcpy.c,v 1.5 2013/03/17 02:23:31 christos Exp $ */ +/* $NetBSD: t_memcpy.c,v 1.6 2017/01/11 18:05:54 christos Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -108,12 +108,8 @@ ATF_TC_BODY(memcpy_basic, tc) if (i != j) runTest(start[i], start[j]); MD5End(mc, result); -#ifdef __NetBSD__ - ATF_REQUIRE_EQ(strcmp(result, goodResult), 0); -#else ATF_REQUIRE_EQ_MSG(strcmp(result, goodResult), 0, "%s != %s", result, goodResult); -#endif } ATF_TC(memccpy_simple); diff --git a/contrib/netbsd-tests/lib/libc/string/t_memmem.c b/contrib/netbsd-tests/lib/libc/string/t_memmem.c index c11b698..5bf60ce 100644 --- a/contrib/netbsd-tests/lib/libc/string/t_memmem.c +++ b/contrib/netbsd-tests/lib/libc/string/t_memmem.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_memmem.c,v 1.2 2011/07/07 08:27:36 jruoho Exp $ */ +/* $NetBSD: t_memmem.c,v 1.3 2017/01/11 18:07:37 christos Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. diff --git a/contrib/netbsd-tests/lib/libc/string/t_strchr.c b/contrib/netbsd-tests/lib/libc/string/t_strchr.c index 4556b2c..5dd9a62 100644 --- a/contrib/netbsd-tests/lib/libc/string/t_strchr.c +++ b/contrib/netbsd-tests/lib/libc/string/t_strchr.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_strchr.c,v 1.1 2011/07/07 08:59:33 jruoho Exp $ */ +/* $NetBSD: t_strchr.c,v 1.2 2017/01/10 15:34:49 christos Exp $ */ /* * Written by J.T. Conklin @@ -58,12 +58,10 @@ ATF_TC_HEAD(strchr_basic, tc) ATF_TC_BODY(strchr_basic, tc) { -#ifdef __FreeBSD__ void *dl_handle; -#endif - unsigned int t, a; char *off; char buf[32]; + unsigned int t, a; const char *tab[] = { "", @@ -248,12 +246,8 @@ ATF_TC_BODY(strchr_basic, tc) "abcdefgh/abcdefgh/", }; -#ifdef __FreeBSD__ dl_handle = dlopen(NULL, RTLD_LAZY); strchr_fn = dlsym(dl_handle, "test_strlen"); -#else - strchr_fn = dlsym(dlopen(0, RTLD_LAZY), "test_strchr"); -#endif if (!strchr_fn) strchr_fn = strchr; @@ -288,9 +282,7 @@ ATF_TC_BODY(strchr_basic, tc) verify_strchr(buf + a, 0xff, t, a); } } -#ifdef __FreeBSD__ (void)dlclose(dl_handle); -#endif } ATF_TP_ADD_TCS(tp) diff --git a/contrib/netbsd-tests/lib/libc/string/t_strerror.c b/contrib/netbsd-tests/lib/libc/string/t_strerror.c index 888a826..99b95b4 100644 --- a/contrib/netbsd-tests/lib/libc/string/t_strerror.c +++ b/contrib/netbsd-tests/lib/libc/string/t_strerror.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_strerror.c,v 1.3 2011/05/10 06:55:27 jruoho Exp $ */ +/* $NetBSD: t_strerror.c,v 1.4 2017/01/10 20:35:49 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,18 +29,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_strerror.c,v 1.3 2011/05/10 06:55:27 jruoho Exp $"); +__RCSID("$NetBSD: t_strerror.c,v 1.4 2017/01/10 20:35:49 christos Exp $"); #include #include +#include /* Needed for sys_nerr on FreeBSD */ #include #include #include -#ifdef __FreeBSD__ -#include -#endif - ATF_TC(strerror_basic); ATF_TC_HEAD(strerror_basic, tc) { diff --git a/contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc b/contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc index 7426851..e7822b7 100644 --- a/contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc +++ b/contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc @@ -1,4 +1,4 @@ -/* $NetBSD: cpp_atomic_ops_linkable.cc,v 1.4 2016/02/27 18:50:39 joerg Exp $ */ +/* $NetBSD: cpp_atomic_ops_linkable.cc,v 1.5 2017/01/11 12:10:26 joerg Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -58,19 +58,13 @@ private: volatile std::atomic m_val; }; -#if defined(__clang__) && defined(__sparc64__) -#define NO_SHORT_ATOMICS -#endif - int main(int argc, char **argv) { -#ifndef NO_SHORT_ATOMICS ATest(); ATest(); ATest(); ATest(); ATest(); -#endif ATest(); ATest(); ATest(); @@ -79,29 +73,23 @@ int main(int argc, char **argv) ATest(); ATest(); #endif -#ifndef NO_SHORT_ATOMICS ATest(); -#endif ATest(); ATest(); -#ifndef NO_SHORT_ATOMICS ATest(); ATest(); ATest(); ATest(); -#endif ATest(); ATest(); #ifdef __HAVE_ATOMIC64_OPS ATest(); ATest(); #endif -#ifndef NO_SHORT_ATOMICS ATest(); ATest(); ATest(); ATest(); -#endif ATest(); ATest(); #ifdef __HAVE_ATOMIC64_OPS @@ -115,5 +103,5 @@ int main(int argc, char **argv) #ifdef __HAVE_ATOMIC64_OPS ATest(); ATest(); -#endif /* NO_SHORT_ATOMICS */ +#endif } diff --git a/contrib/netbsd-tests/lib/libc/sys/t_access.c b/contrib/netbsd-tests/lib/libc/sys/t_access.c index 69d2df2..c537eca 100644 --- a/contrib/netbsd-tests/lib/libc/sys/t_access.c +++ b/contrib/netbsd-tests/lib/libc/sys/t_access.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_access.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $ */ +/* $NetBSD: t_access.c,v 2.2 2017/01/10 22:36:29 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_access.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $"); +__RCSID("$NetBSD: t_access.c,v 1.2 2017/01/10 22:36:29 christos Exp $"); + +#ifdef __FreeBSD__ +#include /* For __FreeBSD_version */ +#endif + +#include + +#include #include #include @@ -38,13 +46,6 @@ __RCSID("$NetBSD: t_access.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $"); #include #include -#include - -#ifdef __FreeBSD__ -#include -#include -#endif - static const char path[] = "access"; static const int mode[4] = { R_OK, W_OK, X_OK, F_OK }; diff --git a/contrib/netbsd-tests/lib/libc/sys/t_chroot.c b/contrib/netbsd-tests/lib/libc/sys/t_chroot.c index 651dc10..1f1c49b 100644 --- a/contrib/netbsd-tests/lib/libc/sys/t_chroot.c +++ b/contrib/netbsd-tests/lib/libc/sys/t_chroot.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_chroot.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $ */ +/* $NetBSD: t_chroot.c,v 1.2 2017/01/10 22:36:29 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,9 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_chroot.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $"); +__RCSID("$NetBSD: t_chroot.c,v 1.2 2017/01/10 22:36:29 christos Exp $"); #include +#include #include #include @@ -42,10 +43,6 @@ __RCSID("$NetBSD: t_chroot.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $"); #include #include -#ifdef __FreeBSD__ -#include -#endif - ATF_TC(chroot_basic); ATF_TC_HEAD(chroot_basic, tc) { diff --git a/contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c b/contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c new file mode 100644 index 0000000..8c1fd03 --- /dev/null +++ b/contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c @@ -0,0 +1,63 @@ +/* $NetBSD: t_clock_nanosleep.c,v 1.1 2016/11/11 15:30:44 njoly Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#include +__RCSID("$NetBSD: t_clock_nanosleep.c,v 1.1 2016/11/11 15:30:44 njoly Exp $"); + +#include +#include + +ATF_TC(clock_nanosleep_remain); +ATF_TC_HEAD(clock_nanosleep_remain, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Check clock_nanosleep(2) remaining time"); +} + +ATF_TC_BODY(clock_nanosleep_remain, tc) +{ + struct timespec rqtp, rmtp; + + rqtp.tv_sec = 0; rqtp.tv_nsec = 0; + rmtp.tv_sec = -1; rmtp.tv_nsec = -1; + ATF_REQUIRE(clock_nanosleep(CLOCK_REALTIME, 0, &rqtp, &rmtp) == 0); + ATF_CHECK(rmtp.tv_sec == 0 && rmtp.tv_nsec == 0); + + ATF_REQUIRE(clock_gettime(CLOCK_REALTIME, &rqtp) == 0); + rmtp.tv_sec = -1; rmtp.tv_nsec = -1; + ATF_REQUIRE(clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &rqtp, &rmtp) == 0); + ATF_CHECK(rmtp.tv_sec == -1 && rmtp.tv_nsec == -1); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, clock_nanosleep_remain); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c b/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c index aa5c4d5..f4ee96b 100644 --- a/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c +++ b/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c @@ -56,6 +56,10 @@ sighandler(int signo) /* Nothing. */ } +#ifdef __FreeBSD__ +#define asm __asm +#endif + static void work(void) { diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mincore.c b/contrib/netbsd-tests/lib/libc/sys/t_mincore.c index c31170f..ab8c33f 100644 --- a/contrib/netbsd-tests/lib/libc/sys/t_mincore.c +++ b/contrib/netbsd-tests/lib/libc/sys/t_mincore.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_mincore.c,v 1.8 2012/06/08 07:18:58 martin Exp $ */ +/* $NetBSD: t_mincore.c,v 1.9 2017/01/10 22:36:29 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -59,9 +59,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_mincore.c,v 1.8 2012/06/08 07:18:58 martin Exp $"); +__RCSID("$NetBSD: t_mincore.c,v 1.9 2017/01/10 22:36:29 christos Exp $"); #include +#include #include #include @@ -74,10 +75,6 @@ __RCSID("$NetBSD: t_mincore.c,v 1.8 2012/06/08 07:18:58 martin Exp $"); #include #include -#ifdef __FreeBSD__ -#include -#endif - static long page = 0; static const char path[] = "mincore"; static size_t check_residency(void *, size_t); diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mmap.c b/contrib/netbsd-tests/lib/libc/sys/t_mmap.c index 0ce4a84..738758c 100644 --- a/contrib/netbsd-tests/lib/libc/sys/t_mmap.c +++ b/contrib/netbsd-tests/lib/libc/sys/t_mmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_mmap.c,v 1.9 2015/02/28 13:57:08 martin Exp $ */ +/* $NetBSD: t_mmap.c,v 1.10 2017/01/10 22:36:29 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -55,10 +55,11 @@ * SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_mmap.c,v 1.9 2015/02/28 13:57:08 martin Exp $"); +__RCSID("$NetBSD: t_mmap.c,v 1.10 2017/01/10 22:36:29 christos Exp $"); #include #include +#include #include #include #include @@ -78,7 +79,6 @@ __RCSID("$NetBSD: t_mmap.c,v 1.9 2015/02/28 13:57:08 martin Exp $"); #ifdef __FreeBSD__ #include -#include #include #endif diff --git a/contrib/netbsd-tests/lib/libc/sys/t_wait.c b/contrib/netbsd-tests/lib/libc/sys/t_wait.c index 027c40d..8653265 100644 --- a/contrib/netbsd-tests/lib/libc/sys/t_wait.c +++ b/contrib/netbsd-tests/lib/libc/sys/t_wait.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_wait.c,v 1.4 2016/04/27 21:14:24 christos Exp $ */ +/* $NetBSD: t_wait.c,v 1.7 2016/11/06 15:04:14 kamil Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_wait.c,v 1.4 2016/04/27 21:14:24 christos Exp $"); +__RCSID("$NetBSD: t_wait.c,v 1.7 2016/11/06 15:04:14 kamil Exp $"); #include #include @@ -64,22 +64,6 @@ ATF_TC_BODY(wait6_invalid, tc) && errno == EINVAL); } -ATF_TC(wait6_noproc); -ATF_TC_HEAD(wait6_noproc, tc) -{ - atf_tc_set_md_var(tc, "descr", - "Test that wait6(2) returns ECHILD with for no processes"); -} - -ATF_TC_BODY(wait6_noproc, tc) -{ - siginfo_t si; - struct wrusage wru; - int st; - ATF_REQUIRE(wait6(P_ALL, 0, &st, WEXITED, &wru, &si) == -1 - && errno == ECHILD); -} - ATF_TC(wait6_exited); ATF_TC_HEAD(wait6_exited, tc) { @@ -96,12 +80,12 @@ ATF_TC_BODY(wait6_exited, tc) switch (pid = fork()) { case -1: - ATF_REQUIRE(pid > 0); + ATF_REQUIRE(pid > 0); case 0: exit(0x5a5a5a5a); /*NOTREACHED*/ default: - ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid); + ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid); ATF_REQUIRE(WIFEXITED(st) && WEXITSTATUS(st) == 0x5a); ATF_REQUIRE(si.si_status = 0x5a5a5a5a); ATF_REQUIRE(si.si_pid == pid); @@ -134,10 +118,10 @@ ATF_TC_BODY(wait6_terminated, tc) sleep(100); /*FALLTHROUGH*/ case -1: - ATF_REQUIRE(pid > 0); + ATF_REQUIRE(pid > 0); default: ATF_REQUIRE(kill(pid, SIGTERM) == 0); - ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid); + ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid); ATF_REQUIRE(WIFSIGNALED(st) && WTERMSIG(st) == SIGTERM); ATF_REQUIRE(si.si_status == SIGTERM); ATF_REQUIRE(si.si_pid == pid); @@ -172,9 +156,9 @@ ATF_TC_BODY(wait6_coredumped, tc) *(char *)8 = 0; /*FALLTHROUGH*/ case -1: - ATF_REQUIRE(pid > 0); + ATF_REQUIRE(pid > 0); default: - ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid); + ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid); ATF_REQUIRE(WIFSIGNALED(st) && WTERMSIG(st) == SIGSEGV && WCOREDUMP(st)); ATF_REQUIRE(si.si_status == SIGSEGV); @@ -210,11 +194,14 @@ ATF_TC_BODY(wait6_stop_and_go, tc) sleep(100); /*FALLTHROUGH*/ case -1: - ATF_REQUIRE(pid > 0); + ATF_REQUIRE(pid > 0); default: ATF_REQUIRE(kill(pid, SIGSTOP) == 0); - ATF_REQUIRE(wait6(P_PID, pid, &st, WSTOPPED, &wru, &si) == pid); + ATF_REQUIRE(wait6(P_PID, pid, &st, WSTOPPED, &wru, &si) == pid); + ATF_REQUIRE(!WIFEXITED(st)); + ATF_REQUIRE(!WIFSIGNALED(st)); ATF_REQUIRE(WIFSTOPPED(st) && WSTOPSIG(st) == SIGSTOP); + ATF_REQUIRE(!WIFCONTINUED(st)); ATF_REQUIRE(si.si_status == SIGSTOP); ATF_REQUIRE(si.si_pid == pid); ATF_REQUIRE(si.si_uid == getuid()); @@ -225,8 +212,11 @@ ATF_TC_BODY(wait6_stop_and_go, tc) #endif ATF_REQUIRE(kill(pid, SIGCONT) == 0); - ATF_REQUIRE(wait6(P_PID, pid, &st, WCONTINUED, &wru, &si) == pid); + ATF_REQUIRE(wait6(P_PID, pid, &st, WCONTINUED, &wru, &si) == pid); + ATF_REQUIRE(!WIFEXITED(st)); + ATF_REQUIRE(!WIFSIGNALED(st)); ATF_REQUIRE(WIFCONTINUED(st)); + ATF_REQUIRE(!WIFSTOPPED(st)); ATF_REQUIRE(si.si_status == SIGCONT); ATF_REQUIRE(si.si_pid == pid); ATF_REQUIRE(si.si_uid == getuid()); @@ -237,8 +227,11 @@ ATF_TC_BODY(wait6_stop_and_go, tc) #endif ATF_REQUIRE(kill(pid, SIGQUIT) == 0); - ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid); + ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid); + ATF_REQUIRE(!WIFEXITED(st)); ATF_REQUIRE(WIFSIGNALED(st) && WTERMSIG(st) == SIGQUIT); + ATF_REQUIRE(!WIFSTOPPED(st)); + ATF_REQUIRE(!WIFCONTINUED(st)); ATF_REQUIRE(si.si_status == SIGQUIT); ATF_REQUIRE(si.si_pid == pid); ATF_REQUIRE(si.si_uid == getuid()); @@ -251,15 +244,80 @@ ATF_TC_BODY(wait6_stop_and_go, tc) } } +ATF_TC(wait6_stopgo_loop); +ATF_TC_HEAD(wait6_stopgo_loop, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that wait6(2) handled stopped/continued process loop"); +} + +ATF_TC_BODY(wait6_stopgo_loop, tc) +{ + siginfo_t si; + struct wrusage wru; + int st; + pid_t pid; + static const struct rlimit rl = { 0, 0 }; + size_t N = 100; + + ATF_REQUIRE(setrlimit(RLIMIT_CORE, &rl) == 0); + switch (pid = fork()) { + case 0: + sleep(100); + /*FALLTHROUGH*/ + case -1: + ATF_REQUIRE(pid > 0); + } + + printf("Before loop of SIGSTOP/SIGCONT sequence %zu times\n", N); + while (N --> 0) { + ATF_REQUIRE(kill(pid, SIGSTOP) == 0); + ATF_REQUIRE(wait6(P_PID, pid, &st, WSTOPPED, &wru, &si) == pid); + ATF_REQUIRE(!WIFEXITED(st)); + ATF_REQUIRE(!WIFSIGNALED(st)); + ATF_REQUIRE(WIFSTOPPED(st) && WSTOPSIG(st) == SIGSTOP); + ATF_REQUIRE(!WIFCONTINUED(st)); + ATF_REQUIRE(si.si_status == SIGSTOP); + ATF_REQUIRE(si.si_pid == pid); + ATF_REQUIRE(si.si_uid == getuid()); + ATF_REQUIRE(si.si_code == CLD_STOPPED); + + ATF_REQUIRE(kill(pid, SIGCONT) == 0); + ATF_REQUIRE(wait6(P_PID, pid, &st, WCONTINUED, &wru, &si) == pid); + ATF_REQUIRE(!WIFEXITED(st)); + ATF_REQUIRE(!WIFSIGNALED(st)); + ATF_REQUIRE(WIFCONTINUED(st)); + ATF_REQUIRE(!WIFSTOPPED(st)); + ATF_REQUIRE(si.si_status == SIGCONT); + ATF_REQUIRE(si.si_pid == pid); + ATF_REQUIRE(si.si_uid == getuid()); + ATF_REQUIRE(si.si_code == CLD_CONTINUED); + } + ATF_REQUIRE(kill(pid, SIGQUIT) == 0); + ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid); + ATF_REQUIRE(!WIFEXITED(st)); + ATF_REQUIRE(WIFSIGNALED(st) && WTERMSIG(st) == SIGQUIT); + ATF_REQUIRE(!WIFSTOPPED(st)); + ATF_REQUIRE(!WIFCONTINUED(st)); + ATF_REQUIRE(si.si_status == SIGQUIT); + ATF_REQUIRE(si.si_pid == pid); + ATF_REQUIRE(si.si_uid == getuid()); + ATF_REQUIRE(si.si_code == CLD_KILLED); +#ifdef __NetBSD__ + printf("user: %ju system: %ju\n", (uintmax_t)si.si_utime, + (uintmax_t)si.si_utime); +#endif +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, wait6_invalid); - ATF_TP_ADD_TC(tp, wait6_noproc); ATF_TP_ADD_TC(tp, wait6_exited); ATF_TP_ADD_TC(tp, wait6_terminated); ATF_TP_ADD_TC(tp, wait6_coredumped); ATF_TP_ADD_TC(tp, wait6_stop_and_go); + ATF_TP_ADD_TC(tp, wait6_stopgo_loop); return atf_no_error(); } diff --git a/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c b/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c new file mode 100644 index 0000000..e5ddcbd --- /dev/null +++ b/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c @@ -0,0 +1,345 @@ +/* $NetBSD: t_wait_noproc.c,v 1.5 2016/11/09 17:50:19 kamil Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#include +__RCSID("$NetBSD: t_wait_noproc.c,v 1.5 2016/11/09 17:50:19 kamil Exp $"); + +#ifdef __FreeBSD__ +#include /* For NBBY -- it's in sys/types.h on NetBSD */ +#endif +#include +#include + +#include +#include + +#include + +#ifndef TWAIT_OPTION +#define TWAIT_OPTION 0 +#endif + +#if TWAIT_OPTION == 0 +ATF_TC(wait); +ATF_TC_HEAD(wait, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that wait(2) returns ECHILD for no child"); +} + +ATF_TC_BODY(wait, tc) +{ + ATF_REQUIRE_ERRNO(ECHILD, wait(NULL) == -1); +} +#endif + +ATF_TC(waitpid); +ATF_TC_HEAD(waitpid, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that waitpid(2) returns ECHILD for WAIT_ANY and option %s", + ___STRING(TWAIT_OPTION)); +} + +ATF_TC_BODY(waitpid, tc) +{ + ATF_REQUIRE_ERRNO(ECHILD, waitpid(WAIT_ANY, NULL, TWAIT_OPTION) == -1); +} + +ATF_TC(waitid); +ATF_TC_HEAD(waitid, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that waitid(2) returns ECHILD for P_ALL and option %s", + ___STRING(TWAIT_OPTION)); +} + +ATF_TC_BODY(waitid, tc) +{ + ATF_REQUIRE_ERRNO(ECHILD, + waitid(P_ALL, 0, NULL, + WTRAPPED | WEXITED | TWAIT_OPTION) == -1); +} + +ATF_TC(wait3); +ATF_TC_HEAD(wait3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that wait3(2) returns ECHILD for no child"); +} + +ATF_TC_BODY(wait3, tc) +{ + ATF_REQUIRE_ERRNO(ECHILD, wait3(NULL, TWAIT_OPTION, NULL) == -1); +} + +ATF_TC(wait4); +ATF_TC_HEAD(wait4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that wait4(2) returns ECHILD for WAIT_ANY and option %s", + ___STRING(TWAIT_OPTION)); +} + +ATF_TC_BODY(wait4, tc) +{ + ATF_REQUIRE_ERRNO(ECHILD, + wait4(WAIT_ANY, NULL, TWAIT_OPTION, NULL) == -1); +} + +ATF_TC(wait6); +ATF_TC_HEAD(wait6, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that wait6(2) returns ECHILD for P_ALL and option %s", + ___STRING(TWAIT_OPTION)); +} + +ATF_TC_BODY(wait6, tc) +{ + ATF_REQUIRE_ERRNO(ECHILD, + wait6(P_ALL, 0, NULL, + WTRAPPED | WEXITED | TWAIT_OPTION, NULL, NULL) == -1); +} + +/* + * Generator of valid combinations of options + * Usage: i = 0; while ((o = get_options_wait6(i++)) != -1) {} + */ +static int +get_options6(size_t pos) +{ + int rv = 0; + size_t n; + + /* + * waitid(2) must specify at least one of WEXITED, WUNTRACED, + * WSTOPPED, WTRAPPED or WCONTINUED. Single option WNOWAIT + * isn't valid. + */ + + const int matrix[] = { + WNOWAIT, /* First in order to blacklist it easily */ + WEXITED, + WUNTRACED, + WSTOPPED, /* SUS compatibility, equal to WUNTRACED */ + WTRAPPED, + WCONTINUED + }; + + const size_t M = (1 << __arraycount(matrix)) - 1; + + /* Skip empty and sole WNOWAIT option */ + pos+=2; + + if (pos > M) + return -1; + + for (n = 0; n < __arraycount(matrix); n++) { + if (pos & __BIT(n)) + rv |= matrix[n]; + } + + return rv; +} + +/* + * Generator of valid combinations of options + * Usage: i = 0; while ((o = get_options_wait4(i++)) != -1) {} + */ +static int +get_options4(size_t pos) +{ + int rv = 0; + size_t n; + + const int special[] = { + 0, +#ifdef __NetBSD__ + WALLSIG, + WALTSIG, + __WALL, /* Linux compatibility, equal to WALLSIG */ + __WCLONE /* Linux compatibility, equal to WALTSIG */ +#endif + }; + + const int matrix[] = { + WNOWAIT, + WEXITED, + WUNTRACED, + WSTOPPED, /* SUS compatibility, equal to WUNTRACED */ + WTRAPPED, + WCONTINUED + }; + + const size_t M = (1 << __arraycount(special)) - 1; + + if (pos < __arraycount(special)) + return special[pos]; + + pos -= __arraycount(special); + + ++pos; /* Don't start with empty mask */ + + if (pos > M) + return -1; + + for (n = 0; n < __arraycount(special); n++) { + if (pos & __BIT(n)) + rv |= matrix[n]; + } + + return rv; +} + +ATF_TC(waitpid_options); +ATF_TC_HEAD(waitpid_options, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that waitpid(2) returns ECHILD for WAIT_ANY and valid " + "combination of options with%s WNOHANG", + TWAIT_OPTION == 0 ? "out" : ""); +} + +ATF_TC_BODY(waitpid_options, tc) +{ + size_t i = 0; + int o; + + while((o = get_options4(i++)) != -1) { + printf("Testing waitpid(2) with options %x\n", o); + + ATF_REQUIRE_ERRNO(ECHILD, + waitpid(WAIT_ANY, NULL, o | TWAIT_OPTION) == -1); + } +} + +ATF_TC(waitid_options); +ATF_TC_HEAD(waitid_options, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that waitid(2) returns ECHILD for P_ALL and valid " + "combination of options with%s WNOHANG", + TWAIT_OPTION == 0 ? "out" : ""); +} + +ATF_TC_BODY(waitid_options, tc) +{ + size_t i = 0; + int o; + + while((o = get_options6(i++)) != -1) { + printf("Testing waitid(2) with options %x\n", o); + + ATF_REQUIRE_ERRNO(ECHILD, + waitid(P_ALL, 0, NULL, o | TWAIT_OPTION) == -1); + } +} + +ATF_TC(wait3_options); +ATF_TC_HEAD(wait3_options, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that wait3(2) returns ECHILD for no child"); +} + +ATF_TC_BODY(wait3_options, tc) +{ + size_t i = 0; + int o; + + while((o = get_options4(i++)) != -1) { + printf("Testing wait3(2) with options %x\n", o); + + ATF_REQUIRE_ERRNO(ECHILD, + wait3(NULL, o | TWAIT_OPTION, NULL) == -1); + } +} + +ATF_TC(wait4_options); +ATF_TC_HEAD(wait4_options, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that wait4(2) returns ECHILD for WAIT_ANY and option %s", + ___STRING(TWAIT_OPTION)); +} + +ATF_TC_BODY(wait4_options, tc) +{ + size_t i = 0; + int o; + + while((o = get_options4(i++)) != -1) { + printf("Testing wait4(2) with options %x\n", o); + + ATF_REQUIRE_ERRNO(ECHILD, + wait4(WAIT_ANY, NULL, o | TWAIT_OPTION, NULL) == -1); + } +} + +ATF_TC(wait6_options); +ATF_TC_HEAD(wait6_options, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Test that wait6(2) returns ECHILD for P_ALL and option %s", + ___STRING(TWAIT_OPTION)); +} + +ATF_TC_BODY(wait6_options, tc) +{ + size_t i = 0; + int o; + + while((o = get_options6(i++)) != -1) { + printf("Testing wait6(2) with options %x\n", o); + + ATF_REQUIRE_ERRNO(ECHILD, + wait6(P_ALL, 0, NULL, o | TWAIT_OPTION, NULL, NULL) == -1); + } +} + +ATF_TP_ADD_TCS(tp) +{ + +#if TWAIT_OPTION == 0 + ATF_TP_ADD_TC(tp, wait); +#endif + ATF_TP_ADD_TC(tp, waitpid); + ATF_TP_ADD_TC(tp, waitid); + ATF_TP_ADD_TC(tp, wait3); + ATF_TP_ADD_TC(tp, wait4); + ATF_TP_ADD_TC(tp, wait6); + + ATF_TP_ADD_TC(tp, waitpid_options); + ATF_TP_ADD_TC(tp, waitid_options); + ATF_TP_ADD_TC(tp, wait3_options); + ATF_TP_ADD_TC(tp, wait4_options); + ATF_TP_ADD_TC(tp, wait6_options); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc_wnohang.c b/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc_wnohang.c new file mode 100644 index 0000000..45a9998 --- /dev/null +++ b/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc_wnohang.c @@ -0,0 +1,30 @@ +/* $NetBSD: t_wait_noproc_wnohang.c,v 1.1 2016/11/06 15:03:30 kamil Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#define TWAIT_OPTION WNOHANG +#include "t_wait_noproc.c" diff --git a/contrib/netbsd-tests/lib/libc/t_cdb.c b/contrib/netbsd-tests/lib/libc/t_cdb.c index 5e88e65..97da4a3 100644 --- a/contrib/netbsd-tests/lib/libc/t_cdb.c +++ b/contrib/netbsd-tests/lib/libc/t_cdb.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_cdb.c,v 1.1 2012/09/27 00:38:57 joerg Exp $ */ +/* $NetBSD: t_cdb.c,v 1.2 2017/01/10 22:24:29 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. @@ -32,9 +32,12 @@ */ #include -__RCSID("$NetBSD: t_cdb.c,v 1.1 2012/09/27 00:38:57 joerg Exp $"); +__RCSID("$NetBSD: t_cdb.c,v 1.2 2017/01/10 22:24:29 christos Exp $"); #include + +#include + #include #include #include diff --git a/contrib/netbsd-tests/lib/libm/t_casinh.c b/contrib/netbsd-tests/lib/libm/t_casinh.c new file mode 100644 index 0000000..f9f93c3 --- /dev/null +++ b/contrib/netbsd-tests/lib/libm/t_casinh.c @@ -0,0 +1,81 @@ +/* $NetBSD: t_casinh.c,v 1.2 2016/09/20 17:19:28 christos Exp $ */ + +/* + * Written by Maya Rashish + * Public domain. + * + * Testing special values of casinh + * Values from ISO/IEC 9899:201x G.6.2.2 + */ + +#include +#include +#include + +#define RE(z) (((double *)(&z))[0]) +#define IM(z) (((double *)(&z))[1]) + +static const struct { + double input_re; + double input_im; + double result_re; + double result_im; +} values[] = { + { +0, +0, +0, +0}, + { +5.032E3, +INFINITY, +INFINITY, +M_PI/2}, + { +INFINITY, +5.023E3, +INFINITY, +0}, + { +INFINITY, +INFINITY, +INFINITY, +M_PI/4}, +#ifdef __HAVE_NANF + { +INFINITY, +NAN, +INFINITY, +NAN}, + { +5.032E3, +NAN, +NAN, +NAN}, /* + FE_INVALID optionally raised */ + { +NAN, +0, +NAN, +0}, + { +NAN, -5.023E3, +NAN, +NAN}, /* + FE_INVALID optionally raised */ + { +NAN, +INFINITY, +INFINITY, +NAN}, /* sign of real part of result unspecified */ + { +NAN, +NAN, +NAN, +NAN}, +#endif +}; + +#ifdef __HAVE_NANF +#define both_nan(a,b) (isnan(a) && isnan(b)) +#else +#define both_nan(a,b) 0 +#endif + +#define crude_equality(a,b) ((a == b) || both_nan(a,b)) + +#define ATF_COMPLEX_EQUAL(a,b) do { \ + complex double ci = casinh(a); \ + ATF_CHECK_MSG(crude_equality(creal(ci),creal(b)) && \ + crude_equality(cimag(ci), cimag(b)), \ + "for casinh([%g,%g]) = [%g,%g] != [%g,%g]", \ + creal(a), cimag(a), creal(ci), cimag(ci), creal(b), cimag(b)); \ +} while (0/*CONSTCOND*/) + + +ATF_TC(casinh); +ATF_TC_HEAD(casinh, tc) +{ + atf_tc_set_md_var(tc, "descr","Check casinh family - special values"); +} + +ATF_TC_BODY(casinh, tc) +{ + complex double input; + complex double result; + unsigned int i; + for (i = 0; i < __arraycount(values); i++) { + RE(input) = values[i].input_re; + IM(input) = values[i].input_im; + RE(result) = values[i].result_re; + IM(result) = values[i].result_im; + ATF_COMPLEX_EQUAL(input, result); + } +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, casinh); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/lib/libm/t_fe_round.c b/contrib/netbsd-tests/lib/libm/t_fe_round.c new file mode 100644 index 0000000..fe805b4 --- /dev/null +++ b/contrib/netbsd-tests/lib/libm/t_fe_round.c @@ -0,0 +1,124 @@ +/* + * Written by Maya Rashish + * Public domain. + * + * Testing IEEE-754 rounding modes (and lrint) + */ + +#include +#include +#ifdef __HAVE_FENV +#include +#include +#include + +/*#pragma STDC FENV_ACCESS ON gcc?? */ + +#define INT 9223L + +#define EPSILON 0.001 + +static const struct { + int round_mode; + double input; + long int expected; +} values[] = { + { FE_DOWNWARD, 3.7, 3}, + { FE_DOWNWARD, -3.7, -4}, + { FE_DOWNWARD, +0, 0}, + { FE_DOWNWARD, -INT-0.01, -INT-1}, + { FE_DOWNWARD, +INT-0.01, INT-1}, + { FE_DOWNWARD, -INT+0.01, -INT}, + { FE_DOWNWARD, +INT+0.01, INT}, +#if 0 /* cpu bugs? */ + { FE_DOWNWARD, -0, -1}, + + { FE_UPWARD, +0, 1}, +#endif + { FE_UPWARD, -0, 0}, + { FE_UPWARD, -123.7, -123}, + { FE_UPWARD, 123.999, 124}, + { FE_UPWARD, -INT-0.01, -INT}, + { FE_UPWARD, +INT-0.01, INT}, + { FE_UPWARD, -INT+0.01, -INT+1}, + { FE_UPWARD, +INT+0.01, INT+1}, + + { FE_TOWARDZERO, 1.99, 1}, + { FE_TOWARDZERO, -1.99, -1}, + { FE_TOWARDZERO, 0.2, 0}, + { FE_TOWARDZERO, INT+0.01, INT}, + { FE_TOWARDZERO, INT-0.01, INT - 1}, + { FE_TOWARDZERO, -INT+0.01, -INT + 1}, + { FE_TOWARDZERO, +0, 0}, + { FE_TOWARDZERO, -0, 0}, + + { FE_TONEAREST, -INT-0.01, -INT}, + { FE_TONEAREST, +INT-0.01, INT}, + { FE_TONEAREST, -INT+0.01, -INT}, + { FE_TONEAREST, +INT+0.01, INT}, + { FE_TONEAREST, -INT-0.501, -INT-1}, + { FE_TONEAREST, +INT-0.501, INT-1}, + { FE_TONEAREST, -INT+0.501, -INT+1}, + { FE_TONEAREST, +INT+0.501, INT+1}, + { FE_TONEAREST, +0, 0}, + { FE_TONEAREST, -0, 0}, +}; + +ATF_TC(fe_round); +ATF_TC_HEAD(fe_round, tc) +{ + atf_tc_set_md_var(tc, "descr","Checking IEEE 754 rounding modes using lrint"); +} + +ATF_TC_BODY(fe_round, tc) +{ + long int received; + + for (unsigned int i = 0; i < __arraycount(values); i++) { + fesetround(values[i].round_mode); + + received = lrint(values[i].input); + ATF_CHECK_MSG( + (labs(received - values[i].expected) < EPSILON), + "lrint rounding wrong, difference too large\n" + "input: %f (index %d): got %ld, expected %ld\n", + values[i].input, i, received, values[i].expected); + + /* Do we get the same rounding mode out? */ + ATF_CHECK_MSG( + (fegetround() == values[i].round_mode), + "Didn't get the same rounding mode out!\n" + "(index %d) fed in %d rounding mode, got %d out\n", + i, fegetround(), values[i].round_mode); + } +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, fe_round); + + return atf_no_error(); +} +#else +ATF_TC(t_nofe_round); + +ATF_TC_HEAD(t_nofe_round, tc) +{ + atf_tc_set_md_var(tc, "descr", + "dummy test case - no fenv.h support"); +} + + +ATF_TC_BODY(t_nofe_round, tc) +{ + atf_tc_skip("no fenv.h support on this architecture"); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, t_nofe_round); + return atf_no_error(); +} + +#endif diff --git a/contrib/netbsd-tests/lib/libm/t_ilogb.c b/contrib/netbsd-tests/lib/libm/t_ilogb.c new file mode 100644 index 0000000..b3c2126 --- /dev/null +++ b/contrib/netbsd-tests/lib/libm/t_ilogb.c @@ -0,0 +1,130 @@ +/* $NetBSD: t_ilogb.c,v 1.6 2016/08/26 08:01:55 christos Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Maya Rashish. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#ifdef __FreeBSD__ +#include +#endif +#include +#include +#include + +#ifndef __HAVE_FENV + +# define ATF_CHECK_RAISED_INVALID +# define ATF_CHECK_RAISED_NOTHING + +#else +# define ATF_CHECK_RAISED_INVALID do { \ + int r = fetestexcept(FE_ALL_EXCEPT); \ + ATF_CHECK_MSG(r == FE_INVALID, "r=%#x != %#x\n", r, FE_INVALID); \ + (void)feclearexcept(FE_ALL_EXCEPT); \ +} while (/*CONSTCOND*/0) + +# define ATF_CHECK_RAISED_NOTHING do { \ + int r = fetestexcept(FE_ALL_EXCEPT); \ + ATF_CHECK_MSG(r == 0, "r=%#x != 0\n", r); \ + (void)feclearexcept(FE_ALL_EXCEPT); \ +} while (/*CONSTCOND*/0) +#endif + +ATF_TC(ilogb); +ATF_TC_HEAD(ilogb, tc) +{ + atf_tc_set_md_var(tc, "descr","Check ilogb family"); +} + +ATF_TC_BODY(ilogb, tc) +{ + + ATF_CHECK(ilogbf(0) == FP_ILOGB0); + ATF_CHECK_RAISED_INVALID; + ATF_CHECK(ilogb(0) == FP_ILOGB0); + ATF_CHECK_RAISED_INVALID; +#ifdef __HAVE_LONG_DOUBLE + ATF_CHECK(ilogbl(0) == FP_ILOGB0); + ATF_CHECK_RAISED_INVALID; +#endif + + ATF_CHECK(ilogbf(-0) == FP_ILOGB0); + ATF_CHECK_RAISED_INVALID; + ATF_CHECK(ilogb(-0) == FP_ILOGB0); + ATF_CHECK_RAISED_INVALID; +#ifdef __HAVE_LONG_DOUBLE + ATF_CHECK(ilogbl(-0) == FP_ILOGB0); + ATF_CHECK_RAISED_INVALID; +#endif + + ATF_CHECK(ilogbf(INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; + ATF_CHECK(ilogb(INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; +#ifdef __HAVE_LONG_DOUBLE + ATF_CHECK(ilogbl(INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; +#endif + + ATF_CHECK(ilogbf(-INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; + ATF_CHECK(ilogb(-INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; +#ifdef __HAVE_LONG_DOUBLE + ATF_CHECK(ilogbl(-INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; +#endif + + ATF_CHECK(ilogbf(1024) == 10); + ATF_CHECK_RAISED_NOTHING; + ATF_CHECK(ilogb(1024) == 10); + ATF_CHECK_RAISED_NOTHING; +#ifdef __HAVE_LONG_DOUBLE + ATF_CHECK(ilogbl(1024) == 10); + ATF_CHECK_RAISED_NOTHING; +#endif + +#ifndef __vax__ + ATF_CHECK(ilogbf(NAN) == FP_ILOGBNAN); + ATF_CHECK_RAISED_INVALID; + ATF_CHECK(ilogb(NAN) == FP_ILOGBNAN); + ATF_CHECK_RAISED_INVALID; +#ifdef __HAVE_LONG_DOUBLE + ATF_CHECK(ilogbl(NAN) == FP_ILOGBNAN); + ATF_CHECK_RAISED_INVALID; +#endif +#endif +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, ilogb); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/lib/libm/t_ldexp.c b/contrib/netbsd-tests/lib/libm/t_ldexp.c index eaf8a4b..251f2ae 100644 --- a/contrib/netbsd-tests/lib/libm/t_ldexp.c +++ b/contrib/netbsd-tests/lib/libm/t_ldexp.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_ldexp.c,v 1.14 2014/11/04 00:20:19 justin Exp $ */ +/* $NetBSD: t_ldexp.c,v 1.16 2016/08/25 00:32:31 maya Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_ldexp.c,v 1.14 2014/11/04 00:20:19 justin Exp $"); +__RCSID("$NetBSD: t_ldexp.c,v 1.16 2016/08/25 00:32:31 maya Exp $"); #include @@ -96,10 +96,12 @@ struct ldexp_test ldexp_overflow[] = { { 1.0, 1023, 1, " inf" }, { 1.0, -1022, 2046, " inf" }, { 1.0, 1025, SKIP, " inf" }, + { 2.0, INT_MAX,SKIP, " inf" }, { -1.0, 1024, SKIP, " -inf" }, { -1.0, 1023, 1, " -inf" }, { -1.0, -1022, 2046, " -inf" }, { -1.0, 1025, SKIP, " -inf" }, + { -2.0, INT_MAX,SKIP, " -inf" }, { 0, 0, 0, NULL } }; @@ -170,10 +172,8 @@ run_test(struct ldexp_test *table) v = ldexp(table->x, table->exp1); - if (table->exp2 == SKIP) - continue; - - v = ldexp(v, table->exp2); + if (table->exp2 != SKIP) + v = ldexp(v, table->exp2); (void)snprintf(outbuf, sizeof(outbuf), FORMAT, v); diff --git a/contrib/netbsd-tests/lib/libm/t_precision.c b/contrib/netbsd-tests/lib/libm/t_precision.c index c01deba..df2d8a3 100644 --- a/contrib/netbsd-tests/lib/libm/t_precision.c +++ b/contrib/netbsd-tests/lib/libm/t_precision.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_precision.c,v 1.2 2014/11/04 00:20:19 justin Exp $ */ +/* $NetBSD: t_precision.c,v 1.3 2016/08/27 10:07:05 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_precision.c,v 1.2 2014/11/04 00:20:19 justin Exp $"); +__RCSID("$NetBSD: t_precision.c,v 1.3 2016/08/27 10:07:05 christos Exp $"); #include @@ -45,7 +45,9 @@ ATF_TC_HEAD(t_precision, tc) } volatile double x = 1; +#if __HAVE_LONG_DOUBLE volatile long double y = 1; +#endif ATF_TC_BODY(t_precision, tc) { @@ -58,7 +60,7 @@ ATF_TC_BODY(t_precision, tc) x += DBL_EPSILON; ATF_CHECK(x == 2.0); -#if !defined(__FreeBSD__) || !defined(__i386__) +#if __HAVE_LONG_DOUBLE y += LDBL_EPSILON; ATF_CHECK(y != 1.0L); y -= 1; diff --git a/contrib/netbsd-tests/lib/libpthread/h_common.h b/contrib/netbsd-tests/lib/libpthread/h_common.h index f4d03bc..2e8b0a1 100644 --- a/contrib/netbsd-tests/lib/libpthread/h_common.h +++ b/contrib/netbsd-tests/lib/libpthread/h_common.h @@ -9,4 +9,10 @@ ATF_REQUIRE_MSG(ret == 0, "%s: %s", #x, strerror(ret)); \ } while (0) +#define PTHREAD_REQUIRE_STATUS(x, v) \ + do { \ + int ret = (x); \ + ATF_REQUIRE_MSG(ret == (v), "%s: %s", #x, strerror(ret)); \ + } while (0) + #endif // H_COMMON_H diff --git a/contrib/netbsd-tests/lib/libpthread/t_mutex.c b/contrib/netbsd-tests/lib/libpthread/t_mutex.c index 1fcd69e..b8d60e6 100644 --- a/contrib/netbsd-tests/lib/libpthread/t_mutex.c +++ b/contrib/netbsd-tests/lib/libpthread/t_mutex.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_mutex.c,v 1.10 2016/07/31 13:01:29 christos Exp $ */ +/* $NetBSD: t_mutex.c,v 1.14 2016/10/31 23:51:20 christos Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,12 +29,17 @@ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_mutex.c,v 1.10 2016/07/31 13:01:29 christos Exp $"); +__RCSID("$NetBSD: t_mutex.c,v 1.14 2016/10/31 23:51:20 christos Exp $"); +#ifdef __FreeBSD__ +#include /* For timespecadd */ +#include /* For UINT16_MAX */ +#endif #include #include #include #include +#include #include #include #include @@ -47,6 +52,31 @@ static pthread_mutex_t mutex; static pthread_mutex_t static_mutex = PTHREAD_MUTEX_INITIALIZER; static int global_x; +#ifdef TIMEDMUTEX +/* This code is used for verifying non-timed specific code */ +static struct timespec ts_lengthy = { + .tv_sec = UINT16_MAX, + .tv_nsec = 0 +}; +/* This code is used for verifying timed-only specific code */ +static struct timespec ts_shortlived = { + .tv_sec = 0, + .tv_nsec = 120 +}; + +static int +mutex_lock(pthread_mutex_t *m, const struct timespec *ts) +{ + struct timespec ts_wait; + ATF_REQUIRE(clock_gettime(CLOCK_REALTIME, &ts_wait) != -1); + timespecadd(&ts_wait, ts, &ts_wait); + + return pthread_mutex_timedlock(m, &ts_wait); +} +#else +#define mutex_lock(a, b) pthread_mutex_lock(a) +#endif + static void * mutex1_threadfunc(void *arg) { @@ -56,7 +86,7 @@ mutex1_threadfunc(void *arg) param = arg; printf("2: Locking mutex\n"); - pthread_mutex_lock(&mutex); + mutex_lock(&mutex, &ts_lengthy); printf("2: Got mutex. *param = %d\n", *param); ATF_REQUIRE_EQ(*param, 20); (*param)++; @@ -81,7 +111,7 @@ ATF_TC_BODY(mutex1, tc) PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); x = 1; - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex1_threadfunc, &x)); printf("1: Before changing the value.\n"); sleep(2); @@ -92,7 +122,7 @@ ATF_TC_BODY(mutex1, tc) printf("1: After releasing the mutex.\n"); PTHREAD_REQUIRE(pthread_join(new, &joinval)); - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("1: Thread joined. X was %d. Return value (int) was %d\n", x, *(int *)joinval); ATF_REQUIRE_EQ(x, 21); @@ -108,7 +138,7 @@ mutex2_threadfunc(void *arg) printf("2: Second thread (%p). Count is %ld\n", pthread_self(), count); while (count--) { - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } @@ -145,7 +175,7 @@ ATF_TC_BODY(mutex2, tc) global_x = 0; count = count2 = 10000000; - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex2_threadfunc, &count2)); printf("1: Thread %p\n", pthread_self()); @@ -153,14 +183,14 @@ ATF_TC_BODY(mutex2, tc) PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); while (count--) { - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } PTHREAD_REQUIRE(pthread_join(new, &joinval)); - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("1: Thread joined. X was %d. Return value (long) was %ld\n", global_x, (long)joinval); ATF_REQUIRE_EQ(global_x, 20000000); @@ -184,7 +214,7 @@ mutex3_threadfunc(void *arg) printf("2: Second thread (%p). Count is %ld\n", pthread_self(), count); while (count--) { - PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex)); + PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex)); } @@ -220,7 +250,7 @@ ATF_TC_BODY(mutex3, tc) global_x = 0; count = count2 = 10000000; - PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex)); + PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex3_threadfunc, &count2)); printf("1: Thread %p\n", pthread_self()); @@ -228,14 +258,14 @@ ATF_TC_BODY(mutex3, tc) PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex)); while (count--) { - PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex)); + PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex)); } PTHREAD_REQUIRE(pthread_join(new, &joinval)); - PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex)); + PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy)); printf("1: Thread joined. X was %d. Return value (long) was %ld\n", global_x, (long)joinval); ATF_REQUIRE_EQ(global_x, 20000000); @@ -260,7 +290,7 @@ mutex4_threadfunc(void *arg) param = arg; printf("2: Locking mutex\n"); - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("2: Got mutex. *param = %d\n", *param); (*param)++; @@ -291,11 +321,11 @@ ATF_TC_BODY(mutex4, tc) PTHREAD_REQUIRE(pthread_mutexattr_destroy(&mattr)); x = 1; - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex4_threadfunc, &x)); printf("1: Before recursively acquiring the mutex.\n"); - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("1: Before releasing the mutex once.\n"); sleep(2); @@ -311,7 +341,7 @@ ATF_TC_BODY(mutex4, tc) PTHREAD_REQUIRE(pthread_join(new, &joinval)); - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("1: Thread joined. X was %d. Return value (int) was %d\n", x, *(int *)joinval); ATF_REQUIRE_EQ(x, 21); @@ -333,7 +363,7 @@ child_func(void* arg) res = _sched_protect(-2); ATF_REQUIRE_EQ_MSG(res, -1, "sched_protect returned %d", res); ATF_REQUIRE_EQ(errno, ENOENT); - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex5)); + PTHREAD_REQUIRE(mutex_lock(&mutex5, &ts_lengthy)); printf("child is owning resource\n"); res = _sched_protect(-2); ATF_REQUIRE_EQ(res, max_fifo_prio); @@ -376,7 +406,7 @@ ATF_TC_BODY(mutex5, tc) max_fifo_prio)); PTHREAD_REQUIRE(pthread_mutex_init(&mutex5, &attr5)); - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex5)); + PTHREAD_REQUIRE(mutex_lock(&mutex5, &ts_lengthy)); printf("enter critical section for main\n"); PTHREAD_REQUIRE(pthread_create(&child, NULL, child_func, NULL)); printf("main starts to sleep\n"); @@ -414,7 +444,7 @@ high_prio(void* arg) high_cnt = 0; sleep(1); } - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex6)); + PTHREAD_REQUIRE(mutex_lock(&mutex6, &ts_lengthy)); if (start == 0) start = 2; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex6)); @@ -446,7 +476,7 @@ low_prio(void* arg) low_cnt = 0; sleep(1); } - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex6)); + PTHREAD_REQUIRE(mutex_lock(&mutex6, &ts_lengthy)); if (start == 0) start = 1; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex6)); @@ -582,6 +612,123 @@ ATF_TC_BODY(mutexattr2, tc) } } +#ifdef TIMEDMUTEX +ATF_TC(timedmutex1); +ATF_TC_HEAD(timedmutex1, tc) +{ + atf_tc_set_md_var(tc, "descr", "Checks timeout on selflock"); +} + +ATF_TC_BODY(timedmutex1, tc) +{ + + printf("Timed mutex-test 1\n"); + + PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); + + printf("Before acquiring mutex\n"); + PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + + printf("Before endeavor to reacquire timed-mutex (timeout expected)\n"); + PTHREAD_REQUIRE_STATUS(mutex_lock(&mutex, &ts_shortlived), + ETIMEDOUT); + + printf("Unlocking mutex\n"); + PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); +} + +ATF_TC(timedmutex2); +ATF_TC_HEAD(timedmutex2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Checks timeout on selflock with timedlock"); +} + +ATF_TC_BODY(timedmutex2, tc) +{ + + printf("Timed mutex-test 2\n"); + + PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); + + printf("Before acquiring mutex with timedlock\n"); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); + + printf("Before endeavor to reacquire timed-mutex (timeout expected)\n"); + PTHREAD_REQUIRE_STATUS(mutex_lock(&mutex, &ts_shortlived), + ETIMEDOUT); + + printf("Unlocking mutex\n"); + PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); +} + +ATF_TC(timedmutex3); +ATF_TC_HEAD(timedmutex3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Checks timeout on selflock in a new thread"); +} + +static void * +timedmtx_thrdfunc(void *arg) +{ + printf("Before endeavor to reacquire timed-mutex (timeout expected)\n"); + PTHREAD_REQUIRE_STATUS(mutex_lock(&mutex, &ts_shortlived), + ETIMEDOUT); + + return NULL; +} + +ATF_TC_BODY(timedmutex3, tc) +{ + pthread_t new; + + printf("Timed mutex-test 3\n"); + + PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); + + printf("Before acquiring mutex with timedlock\n"); + PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + + printf("Before creating new thread\n"); + PTHREAD_REQUIRE(pthread_create(&new, NULL, timedmtx_thrdfunc, NULL)); + + printf("Before joining the mutex\n"); + PTHREAD_REQUIRE(pthread_join(new, NULL)); + + printf("Unlocking mutex\n"); + PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); +} + +ATF_TC(timedmutex4); +ATF_TC_HEAD(timedmutex4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Checks timeout on selflock with timedlock in a new thread"); +} + +ATF_TC_BODY(timedmutex4, tc) +{ + pthread_t new; + + printf("Timed mutex-test 4\n"); + + PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); + + printf("Before acquiring mutex with timedlock\n"); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); + + printf("Before creating new thread\n"); + PTHREAD_REQUIRE(pthread_create(&new, NULL, timedmtx_thrdfunc, NULL)); + + printf("Before joining the mutex\n"); + PTHREAD_REQUIRE(pthread_join(new, NULL)); + + printf("Unlocking mutex\n"); + PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); +} +#endif + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, mutex1); @@ -594,6 +741,13 @@ ATF_TP_ADD_TCS(tp) #endif ATF_TP_ADD_TC(tp, mutexattr1); ATF_TP_ADD_TC(tp, mutexattr2); - + +#ifdef TIMEDMUTEX + ATF_TP_ADD_TC(tp, timedmutex1); + ATF_TP_ADD_TC(tp, timedmutex2); + ATF_TP_ADD_TC(tp, timedmutex3); + ATF_TP_ADD_TC(tp, timedmutex4); +#endif + return atf_no_error(); } diff --git a/contrib/netbsd-tests/lib/libpthread/t_timedmutex.c b/contrib/netbsd-tests/lib/libpthread/t_timedmutex.c new file mode 100644 index 0000000..4f71acd --- /dev/null +++ b/contrib/netbsd-tests/lib/libpthread/t_timedmutex.c @@ -0,0 +1,30 @@ +/* $NetBSD: t_timedmutex.c,v 1.2 2016/10/31 16:21:23 christos Exp $ */ + +/* + * Copyright (c) 2008 The NetBSD Foundation, Inc. + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#define TIMEDMUTEX +#include "t_mutex.c" diff --git a/contrib/netbsd-tests/lib/librumpclient/h_execthr.c b/contrib/netbsd-tests/lib/librumpclient/h_execthr.c index f653fe6..c209375 100644 --- a/contrib/netbsd-tests/lib/librumpclient/h_execthr.c +++ b/contrib/netbsd-tests/lib/librumpclient/h_execthr.c @@ -1,4 +1,4 @@ -/* $NetBSD: h_execthr.c,v 1.3 2014/08/13 00:03:00 pooka Exp $ */ +/* $NetBSD: h_execthr.c,v 1.7 2016/11/24 00:37:29 dholland Exp $ */ /* * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -42,6 +42,14 @@ #include #include +//#define VERBOSE + +#ifdef VERBOSE +#define SAY(...) printf(__VA_ARGS__) +#else +#define SAY(...) +#endif + static int canreturn = 0; /* @@ -103,6 +111,7 @@ main(int argc, char *argv[], char *envp[]) else execd = 0; sprintf(nexec, "%d", execd+1); + SAY("execd: %d\n", execd); if (rumpclient_init() == -1) { if (execd) @@ -111,33 +120,43 @@ main(int argc, char *argv[], char *envp[]) err(1, "init"); } mypid = rump_sys_getpid(); + SAY("rumpclient_init finished.\n"); if (execd) { canreturn = 1; - if (pthread_create(&pt, NULL, - wrk, (void *)(uintptr_t)P2_0) != 0) - errx(1, "exec pthread_create"); + errno = pthread_create(&pt, NULL, + wrk, (void *)(uintptr_t)P2_0); + if (errno != 0) + err(1, "exec pthread_create"); + SAY("startup pthread_create finished.\n"); i = 37; rump_sys_write(P2_1, &i, sizeof(i)); pthread_join(pt, NULL); + SAY("startup pthread_join finished.\n"); n = rump_sys_read(P1_0, &i, sizeof(i)); if (n != -1 || errno != EBADF) errx(1, "post-exec cloexec works"); + SAY("startup rump_sys_read finished.\n"); getproc(mypid, &p); + SAY("startup getproc finished.\n"); if (p.p_nlwps != 2) errx(1, "invalid nlwps: %lld", (long long)p.p_nlwps); /* we passed? */ - if (execd > 10) + if (execd > 10) { + SAY("done.\n"); exit(0); + } rump_sys_close(P2_0); rump_sys_close(P2_1); } + SAY("making pipes...\n"); + if (rump_sys_pipe(p1) == -1) err(1, "pipe1"); if (p1[0] != P1_0 || p1[1] != P1_1) @@ -151,32 +170,47 @@ main(int argc, char *argv[], char *envp[]) if (rump_sys_fcntl(p1[1], F_SETFD, FD_CLOEXEC) == -1) err(1, "cloexec"); - for (i = 0; i < NTHR; i++) - if (pthread_create(&pt, NULL, - wrk, (void *)(uintptr_t)p1[0]) != 0) - errx(1, "pthread_create 1 %d", i); + SAY("making threads...\n"); + + for (i = 0; i < NTHR; i++) { + errno = pthread_create(&pt, NULL, + wrk, (void *)(uintptr_t)p1[0]); + if (errno != 0) + err(1, "pthread_create 1 %d", i); + } + + for (i = 0; i < NTHR; i++) { + errno = pthread_create(&pt, NULL, + wrk, (void *)(uintptr_t)p2[0]); + if (errno != 0) + err(1, "pthread_create 2 %d", i); + } - for (i = 0; i < NTHR; i++) - if (pthread_create(&pt, NULL, - wrk, (void *)(uintptr_t)p2[0]) != 0) - errx(1, "pthread_create 2 %d", i); + SAY("waiting for threads to start...\n"); /* wait for all the threads to be enjoying themselves */ for (;;) { getproc(mypid, &p); + SAY("getproc finished.\n"); if (p.p_nlwps == 2*NTHR + 2) break; usleep(10000); } + SAY("making some more threads start...\n"); + /* * load up one more (big) set. these won't start executing, though, * but we're interested in if they create blockage */ - for (i = 0; i < 3*NTHR; i++) - if (pthread_create(&pt, NULL, - wrk, (void *)(uintptr_t)p1[0]) != 0) - errx(1, "pthread_create 1 %d", i); + for (i = 0; i < 3*NTHR; i++) { + errno = pthread_create(&pt, NULL, + wrk, (void *)(uintptr_t)p1[0]); + if (errno != 0) + err(1, "pthread_create 3 %d", i); + } + + SAY("calling exec...\n"); /* then, we exec! */ execarg[0] = argv[0]; diff --git a/contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh b/contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh index 718dfdc..411be33 100755 --- a/contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh +++ b/contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_tcpip.sh,v 1.17 2016/08/11 21:29:44 kre Exp $ +# $NetBSD: t_tcpip.sh,v 1.18 2016/08/13 11:22:11 christos Exp $ # # Copyright (c) 2011 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,7 +25,8 @@ # POSSIBILITY OF SUCH DAMAGE. # -rumpnetsrv='rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpdev' +rumpnetlibs="-lrumpnet -lrumpnet_net -lrumpnet_netinet6 -lrumpnet_netinet" +rumpnetsrv="rump_server $rumpnetlibs -lrumpdev" export RUMP_SERVER=unix://csock atf_test_case http cleanup @@ -37,7 +38,7 @@ http_head() http_body() { - atf_check -s exit:0 ${rumpnetsrv} -lrumpnet_netinet6 ${RUMP_SERVER} + atf_check -s exit:0 ${rumpnetsrv} ${RUMP_SERVER} # start bozo in daemon mode atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \ diff --git a/contrib/netbsd-tests/lib/libusbhid/t_usbhid.c b/contrib/netbsd-tests/lib/libusbhid/t_usbhid.c index f20652a..2766da2 100644 --- a/contrib/netbsd-tests/lib/libusbhid/t_usbhid.c +++ b/contrib/netbsd-tests/lib/libusbhid/t_usbhid.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_usbhid.c,v 1.11 2016/01/07 16:10:49 jakllsch Exp $ */ +/* $NetBSD: t_usbhid.c,v 1.12 2016/08/17 12:10:42 jakllsch Exp $ */ /* * Copyright (c) 2016 Jonathan A. Kollasch @@ -27,7 +27,7 @@ */ #include -__RCSID("$NetBSD: t_usbhid.c,v 1.11 2016/01/07 16:10:49 jakllsch Exp $"); +__RCSID("$NetBSD: t_usbhid.c,v 1.12 2016/08/17 12:10:42 jakllsch Exp $"); #include @@ -244,6 +244,9 @@ ATF_TC_BODY(check_hid_get_data, tc) int32_t data; uint32_t udat; + atf_tc_expect_fail("only the 32-bit opcode works, " + "8 and 16-bit is broken"); + ATF_REQUIRE((hrd = hid_use_report_desc( range_test_report_descriptor, __arraycount(range_test_report_descriptor))) != NULL); diff --git a/contrib/netbsd-tests/net/arp/t_arp.sh b/contrib/netbsd-tests/net/arp/t_arp.sh index ab55eb3..04e2f70 100755 --- a/contrib/netbsd-tests/net/arp/t_arp.sh +++ b/contrib/netbsd-tests/net/arp/t_arp.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_arp.sh,v 1.16 2016/06/21 05:04:16 ozaki-r Exp $ +# $NetBSD: t_arp.sh,v 1.22 2016/11/25 08:51:16 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,10 +25,6 @@ # POSSIBILITY OF SUCH DAMAGE. # -inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif" -inetserver="$inetserver -lrumpdev -lrumpnet_tap" -HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes" - SOCKSRC=unix://commsock1 SOCKDST=unix://commsock2 IP4SRC=10.0.1.1 @@ -36,7 +32,7 @@ IP4DST=10.0.1.2 IP4DST_PROXYARP1=10.0.1.3 IP4DST_PROXYARP2=10.0.1.4 -DEBUG=false +DEBUG=${DEBUG:-false} TIMEOUT=1 atf_test_case arp_cache_expiration_5s cleanup @@ -106,9 +102,9 @@ arp_static_head() setup_dst_server() { + + rump_server_add_iface $SOCKDST shmif0 bus1 export RUMP_SERVER=$SOCKDST - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 atf_check -s exit:0 rump.ifconfig shmif0 inet $IP4DST/24 atf_check -s exit:0 rump.ifconfig shmif0 up atf_check -s exit:0 rump.ifconfig -w 10 @@ -127,8 +123,7 @@ setup_src_server() atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.arp.keep=$keep # Setup an interface - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 + rump_server_add_iface $SOCKSRC shmif0 bus1 atf_check -s exit:0 rump.ifconfig shmif0 inet $IP4SRC/24 atf_check -s exit:0 rump.ifconfig shmif0 up atf_check -s exit:0 rump.ifconfig -w 10 @@ -145,8 +140,8 @@ test_cache_expiration() local arp_keep=$1 local bonus=2 - atf_check -s exit:0 ${inetserver} $SOCKSRC - atf_check -s exit:0 ${inetserver} $SOCKDST + rump_server_start $SOCKSRC + rump_server_start $SOCKDST setup_dst_server setup_src_server $arp_keep @@ -172,12 +167,16 @@ test_cache_expiration() arp_cache_expiration_5s_body() { + test_cache_expiration 5 + rump_server_destroy_ifaces } arp_cache_expiration_10s_body() { + test_cache_expiration 10 + rump_server_destroy_ifaces } arp_command_body() @@ -185,8 +184,8 @@ arp_command_body() local arp_keep=5 local bonus=2 - atf_check -s exit:0 ${inetserver} $SOCKSRC - atf_check -s exit:0 ${inetserver} $SOCKDST + rump_server_start $SOCKSRC + rump_server_start $SOCKDST setup_dst_server setup_src_server $arp_keep @@ -257,7 +256,7 @@ arp_command_body() $DEBUG && rump.arp -n -a #atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.10 - return 0 + rump_server_destroy_ifaces } make_pkt_str_arpreq() @@ -273,12 +272,12 @@ arp_garp_body() { local pkt= - atf_check -s exit:0 ${inetserver} $SOCKSRC + rump_server_start $SOCKSRC + export RUMP_SERVER=$SOCKSRC # Setup an interface - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 + rump_server_add_iface $SOCKSRC shmif0 bus1 atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24 atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 alias atf_check -s exit:0 rump.ifconfig shmif0 up @@ -304,6 +303,8 @@ arp_garp_body() atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'" pkt=$(make_pkt_str_arpreq 10.0.0.4 10.0.0.4) atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'" + + rump_server_destroy_ifaces } arp_cache_overwriting_body() @@ -311,8 +312,8 @@ arp_cache_overwriting_body() local arp_keep=5 local bonus=2 - atf_check -s exit:0 ${inetserver} $SOCKSRC - atf_check -s exit:0 ${inetserver} $SOCKDST + rump_server_start $SOCKSRC + rump_server_start $SOCKDST setup_dst_server setup_src_server $arp_keep @@ -341,7 +342,7 @@ arp_cache_overwriting_body() atf_check -s exit:0 -o match:'b2:a0:20:00:00:ff' rump.arp -n 10.0.1.10 $DEBUG && rump.arp -n -a - return 0 + rump_server_destroy_ifaces } make_pkt_str_arprep() @@ -363,36 +364,21 @@ make_pkt_str_garp() echo $pkt } -extract_new_packets() -{ - local old=./old - - if [ ! -f $old ]; then - old=/dev/null - fi - - shmif_dumpbus -p - bus1 2>/dev/null| \ - tcpdump -n -e -r - 2>/dev/null > ./new - diff -u $old ./new |grep '^+' |cut -d '+' -f 2 > ./diff - mv -f ./new ./old - cat ./diff -} - test_proxy_arp() { local arp_keep=5 local opts= title= flags= local type=$1 - atf_check -s exit:0 ${inetserver} $SOCKSRC - atf_check -s exit:0 ${inetserver} $SOCKDST + rump_server_start $SOCKSRC + rump_server_start $SOCKDST tap setup_dst_server setup_src_server $arp_keep export RUMP_SERVER=$SOCKDST atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.ip.forwarding=1 - macaddr_dst=$(rump.ifconfig shmif0 |awk '/address/ {print $2;}') + macaddr_dst=$(get_macaddr $SOCKDST shmif0) if [ "$type" = "pub" ]; then opts="pub" @@ -416,7 +402,7 @@ test_proxy_arp() rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1 # Flushing - extract_new_packets > ./out + extract_new_packets bus1 > ./out # Set up proxy ARP entry export RUMP_SERVER=$SOCKDST @@ -435,7 +421,7 @@ test_proxy_arp() rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1 fi - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out pkt1=$(make_pkt_str_arprep $IP4DST_PROXYARP1 $macaddr_dst) @@ -461,7 +447,7 @@ test_proxy_arp() atf_check -s not-exit:0 -o ignore -e ignore \ rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP2 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out # ARP reply should be sent @@ -482,12 +468,14 @@ arp_proxy_arp_pub_body() { test_proxy_arp pub + rump_server_destroy_ifaces } arp_proxy_arp_pubproxy_body() { test_proxy_arp pubproxy + rump_server_destroy_ifaces } arp_link_activation_body() @@ -495,14 +483,14 @@ arp_link_activation_body() local arp_keep=5 local bonus=2 - atf_check -s exit:0 ${inetserver} $SOCKSRC - atf_check -s exit:0 ${inetserver} $SOCKDST + rump_server_start $SOCKSRC + rump_server_start $SOCKDST setup_dst_server setup_src_server $arp_keep # flush old packets - extract_new_packets > ./out + extract_new_packets bus1 > ./out export RUMP_SERVER=$SOCKSRC @@ -510,7 +498,7 @@ arp_link_activation_body() b2:a1:00:00:00:01 atf_check -s exit:0 sleep 1 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out pkt=$(make_pkt_str_arpreq $IP4SRC $IP4SRC) @@ -520,12 +508,14 @@ arp_link_activation_body() b2:a1:00:00:00:02 active atf_check -s exit:0 sleep 1 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out pkt=$(make_pkt_str_arpreq $IP4SRC $IP4SRC) atf_check -s exit:0 -x \ "cat ./out |grep '$pkt' |grep -q 'b2:a1:00:00:00:02'" + + rump_server_destroy_ifaces } arp_static_body() @@ -533,14 +523,13 @@ arp_static_body() local arp_keep=5 local macaddr_src= - atf_check -s exit:0 ${inetserver} $SOCKSRC - atf_check -s exit:0 ${inetserver} $SOCKDST + rump_server_start $SOCKSRC + rump_server_start $SOCKDST setup_dst_server setup_src_server $arp_keep - export RUMP_SERVER=$SOCKSRC - macaddr_src=$(rump.ifconfig shmif0 |awk '/address/ {print $2;}') + macaddr_src=$(get_macaddr $SOCKSRC shmif0) # Set a (valid) static ARP entry for the src server export RUMP_SERVER=$SOCKDST @@ -551,37 +540,8 @@ arp_static_body() # Test receiving an ARP request with the static ARP entry (as spa/sha) export RUMP_SERVER=$SOCKSRC atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP4DST -} -cleanup() -{ - env RUMP_SERVER=$SOCKSRC rump.halt - env RUMP_SERVER=$SOCKDST rump.halt -} - -dump_src() -{ - export RUMP_SERVER=$SOCKSRC - rump.netstat -nr - rump.arp -n -a - rump.ifconfig - $HIJACKING dmesg -} - -dump_dst() -{ - export RUMP_SERVER=$SOCKDST - rump.netstat -nr - rump.arp -n -a - rump.ifconfig - $HIJACKING dmesg -} - -dump() -{ - dump_src - dump_dst - shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - + rump_server_destroy_ifaces } arp_cache_expiration_5s_cleanup() @@ -604,9 +564,8 @@ arp_command_cleanup() arp_garp_cleanup() { - $DEBUG && dump_src - $DEBUG && shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - - env RUMP_SERVER=$SOCKSRC rump.halt + $DEBUG && dump + cleanup } arp_cache_overwriting_cleanup() diff --git a/contrib/netbsd-tests/net/arp/t_dad.sh b/contrib/netbsd-tests/net/arp/t_dad.sh index aefcb0b..57a7d4b0 100755 --- a/contrib/netbsd-tests/net/arp/t_dad.sh +++ b/contrib/netbsd-tests/net/arp/t_dad.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_dad.sh,v 1.7 2016/08/10 22:05:07 kre Exp $ +# $NetBSD: t_dad.sh,v 1.13 2016/11/25 08:51:16 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,14 +25,10 @@ # POSSIBILITY OF SUCH DAMAGE. # -inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif" -inetserver="${inetserver} -lrumpdev" -HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes" - SOCKLOCAL=unix://commsock1 SOCKPEER=unix://commsock2 -DEBUG=false +DEBUG=${DEBUG:-false} atf_test_case dad_basic cleanup atf_test_case dad_duplicated cleanup @@ -54,10 +50,9 @@ setup_server() local sock=$1 local ip=$2 - export RUMP_SERVER=$sock + rump_server_add_iface $sock shmif0 bus1 - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 + export RUMP_SERVER=$sock atf_check -s exit:0 rump.ifconfig shmif0 inet $ip/24 atf_check -s exit:0 rump.ifconfig shmif0 up atf_check -s exit:0 rump.ifconfig -w 10 @@ -74,30 +69,15 @@ make_pkt_str() echo $pkt } -extract_new_packets() -{ - local old=./old - - if [ ! -f $old ]; then - old=/dev/null - fi - - shmif_dumpbus -p - bus1 2>/dev/null| \ - tcpdump -n -e -r - 2>/dev/null > ./new - diff -u $old ./new |grep '^+' |cut -d '+' -f 2 > ./diff - mv -f ./new ./old - cat ./diff -} - dad_basic_body() { local pkt= - atf_check -s exit:0 ${inetserver} $SOCKLOCAL + rump_server_start $SOCKLOCAL + rump_server_add_iface $SOCKLOCAL shmif0 bus1 + export RUMP_SERVER=$SOCKLOCAL - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24 atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 alias $DEBUG && rump.ifconfig shmif0 @@ -107,13 +87,13 @@ dad_basic_body() $DEBUG && cat ./out # The primary address doesn't start with tentative state - atf_check -s not-exit:0 -x "cat ./out |grep 10.0.0.1 |grep -q tentative" + atf_check -s not-exit:0 -x "cat ./out |grep 10.0.0.1 |grep -iq tentative" # The alias address starts with tentative state # XXX we have no stable way to check this, so skip for now - #atf_check -s exit:0 -x "cat ./out |grep 10.0.0.2 |grep -q tentative" + #atf_check -s exit:0 -x "cat ./out |grep 10.0.0.2 |grep -iq tentative" atf_check -s exit:0 sleep 2 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out # Check DAD probe packets @@ -127,14 +107,14 @@ dad_basic_body() atf_check -s exit:0 rump.ifconfig -w 10 # Give a chance to send a DAD announce packet atf_check -s exit:0 sleep 1 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out # Check the DAD announce packet pkt=$(make_pkt_str 10.0.0.2 10.0.0.2) atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" # The alias address left tentative - atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.2 |grep -q tentative" + atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.2 |grep -iq tentative" # # Add a new address on the fly @@ -143,11 +123,11 @@ dad_basic_body() # The new address starts with tentative state # XXX we have no stable way to check this, so skip for now - #atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -q tentative" + #atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -iq tentative" # Check DAD probe packets atf_check -s exit:0 sleep 2 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out pkt=$(make_pkt_str 10.0.0.3 0.0.0.0) atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" @@ -156,14 +136,16 @@ dad_basic_body() atf_check -s exit:0 rump.ifconfig -w 10 # Give a chance to send a DAD announce packet atf_check -s exit:0 sleep 1 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out # Check the DAD announce packet pkt=$(make_pkt_str 10.0.0.3 10.0.0.3) atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" # The new address left tentative - atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -q tentative" + atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -iq tentative" + + rump_server_destroy_ifaces } dad_duplicated_body() @@ -172,8 +154,8 @@ dad_duplicated_body() local localip2=10.0.1.11 local peerip=10.0.1.2 - atf_check -s exit:0 ${inetserver} $SOCKLOCAL - atf_check -s exit:0 ${inetserver} $SOCKPEER + rump_server_start $SOCKLOCAL + rump_server_start $SOCKPEER setup_server $SOCKLOCAL $localip1 setup_server $SOCKPEER $peerip @@ -181,7 +163,7 @@ dad_duplicated_body() export RUMP_SERVER=$SOCKLOCAL # The primary address isn't marked as duplicated - atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip1 |grep -q duplicated" + atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip1 |grep -iq duplicated" # # Add a new address duplicated with the peer server @@ -190,50 +172,20 @@ dad_duplicated_body() atf_check -s exit:0 sleep 1 # The new address is marked as duplicated - atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep $peerip |grep -q duplicated" + atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep $peerip |grep -iq duplicated" # A unique address isn't marked as duplicated atf_check -s exit:0 rump.ifconfig shmif0 inet $localip2 alias atf_check -s exit:0 sleep 1 - atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip2 |grep -q duplicated" -} - -cleanup() -{ - env RUMP_SERVER=$SOCKLOCAL rump.halt - env RUMP_SERVER=$SOCKPEER rump.halt -} - -dump_local() -{ - export RUMP_SERVER=$SOCKLOCAL - rump.netstat -nr - rump.arp -n -a - rump.ifconfig - $HIJACKING dmesg -} + atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip2 |grep -iq duplicated" -dump_peer() -{ - export RUMP_SERVER=$SOCKPEER - rump.netstat -nr - rump.arp -n -a - rump.ifconfig - $HIJACKING dmesg -} - -dump() -{ - dump_local - dump_peer - shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - + rump_server_destroy_ifaces } dad_basic_cleanup() { - $DEBUG && dump_local - $DEBUG && shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - - env RUMP_SERVER=$SOCKLOCAL rump.halt + $DEBUG && dump + cleanup } dad_duplicated_cleanup() diff --git a/contrib/netbsd-tests/net/icmp/t_icmp6_redirect.sh b/contrib/netbsd-tests/net/icmp/t_icmp6_redirect.sh index c12017d..5dcdc9c 100755 --- a/contrib/netbsd-tests/net/icmp/t_icmp6_redirect.sh +++ b/contrib/netbsd-tests/net/icmp/t_icmp6_redirect.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_icmp6_redirect.sh,v 1.2 2016/08/10 22:17:44 kre Exp $ +# $NetBSD: t_icmp6_redirect.sh,v 1.7 2016/11/25 08:51:16 ozaki-r Exp $ # # Copyright (c) 2015 Internet Initiative Japan Inc. # All rights reserved. @@ -24,8 +24,6 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # -netserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_shmif" -netserver="${netserver} -lrumpnet_netinet -lrumpnet_netinet6 -lrumpdev" SOCK_LOCAL=unix://commsock1 SOCK_PEER=unix://commsock2 @@ -44,50 +42,38 @@ IP6IF0_GW2=fc00:1::3 REDIRECT_TIMEOUT=5 -DEBUG=true +DEBUG=${DEBUG:-true} -get_lladdr() -{ - - export RUMP_SERVER=${1} - rump.ifconfig ${2} inet6 | awk "/fe80/ {sub(/%$2/, \"\"); print \$2;}" - unset RUMP_SERVER - - return 0 -} +atf_test_case icmp6_redirect_basic cleanup -atf_test_case basic cleanup - -basic_head() +icmp6_redirect_basic_head() { atf_set "descr" "Test for the basically function of the ICMP6 redirect" atf_set "require.progs" "rump_server rump.route rump.ping rump.ifconfig" } -basic_body() +icmp6_redirect_basic_body() { local gw1_lladdr0= local gw1_lladdr1= local gw2_lladdr0= - atf_check -s exit:0 ${netserver} ${SOCK_LOCAL} - atf_check -s exit:0 ${netserver} ${SOCK_PEER} - atf_check -s exit:0 ${netserver} ${SOCK_GW1} - atf_check -s exit:0 ${netserver} ${SOCK_GW2} + rump_server_start $SOCK_LOCAL netinet6 + rump_server_start $SOCK_PEER netinet6 + rump_server_start $SOCK_GW1 netinet6 + rump_server_start $SOCK_GW2 netinet6 # # Setup # # Setup gateway #1 (real gateway) export RUMP_SERVER=${SOCK_GW1} - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS1} + rump_server_add_iface $SOCK_GW1 shmif0 $BUS1 + rump_server_add_iface $SOCK_GW1 shmif1 $BUS2 + atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6IF0_GW1} atf_check -s exit:0 rump.ifconfig shmif0 up - - atf_check -s exit:0 rump.ifconfig shmif1 create - atf_check -s exit:0 rump.ifconfig shmif1 linkstr ${BUS2} atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6IF1_GW1} atf_check -s exit:0 rump.ifconfig shmif1 up @@ -95,13 +81,12 @@ basic_body() net.inet6.ip6.forwarding=1 unset RUMP_SERVER - gw1_lladdr0=`get_lladdr ${SOCK_GW1} shmif0` - gw1_lladdr1=`get_lladdr ${SOCK_GW1} shmif1` + gw1_lladdr0=`get_linklocal_addr ${SOCK_GW1} shmif0` + gw1_lladdr1=`get_linklocal_addr ${SOCK_GW1} shmif1` # Setup a peer behind gateway #1 export RUMP_SERVER=${SOCK_PEER} - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS2} + rump_server_add_iface $SOCK_PEER shmif0 $BUS2 atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6IF0_PEER} atf_check -s exit:0 rump.ifconfig shmif0 up atf_check -s exit:0 -o ignore rump.route add \ @@ -110,8 +95,7 @@ basic_body() # Setup gateway #2 (fake gateway) export RUMP_SERVER=${SOCK_GW2} - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS1} + rump_server_add_iface $SOCK_GW2 shmif0 $BUS1 atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6IF0_GW2} atf_check -s exit:0 rump.ifconfig shmif0 up @@ -121,11 +105,10 @@ basic_body() net.inet6.ip6.forwarding=1 unset RUMP_SERVER - gw2_lladdr0=`get_lladdr ${SOCK_GW2} shmif0` + gw2_lladdr0=`get_linklocal_addr ${SOCK_GW2} shmif0` export RUMP_SERVER=${SOCK_LOCAL} - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS1} + rump_server_add_iface $SOCK_LOCAL shmif0 $BUS1 atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6IF0_LOCAL} atf_check -s exit:0 rump.ifconfig shmif0 up @@ -152,20 +135,18 @@ basic_body() atf_check -s exit:0 -o not-match:"gateway: ${gw1_lladdr0}" rump.route get \ -inet6 ${IP6IF0_PEER} - unset RUMP_SERVER + rump_server_destroy_ifaces } -basic_cleanup() +icmp6_redirect_basic_cleanup() { - env RUMP_SERVER=$SOCK_LOCAL rump.halt - env RUMP_SERVER=$SOCK_PEER rump.halt - env RUMP_SERVER=$SOCK_GW1 rump.halt - env RUMP_SERVER=$SOCK_GW2 rump.halt + $DEBUG && dump + cleanup } atf_init_test_cases() { - atf_add_test_case basic + atf_add_test_case icmp6_redirect_basic } diff --git a/contrib/netbsd-tests/net/icmp/t_icmp_redirect.sh b/contrib/netbsd-tests/net/icmp/t_icmp_redirect.sh index 730f2d2..6697216 100755 --- a/contrib/netbsd-tests/net/icmp/t_icmp_redirect.sh +++ b/contrib/netbsd-tests/net/icmp/t_icmp_redirect.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_icmp_redirect.sh,v 1.3 2016/08/10 22:17:44 kre Exp $ +# $NetBSD: t_icmp_redirect.sh,v 1.6 2016/11/25 08:51:16 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -27,8 +27,6 @@ # Most codes are derived from tests/net/route/t_flags.sh -netserver=\ -"rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif -lrumpdev" SOCK_LOCAL=unix://commsock1 SOCK_PEER=unix://commsock2 SOCK_GW=unix://commsock3 @@ -36,7 +34,7 @@ BUS=bus1 BUS2=bus2 REDIRECT_TIMEOUT=5 -DEBUG=false +DEBUG=${DEBUG:-false} atf_test_case icmp_redirect_timeout cleanup @@ -50,11 +48,10 @@ icmp_redirect_timeout_head() setup_local() { - atf_check -s exit:0 ${netserver} ${SOCK_LOCAL} + rump_server_start $SOCK_LOCAL + rump_server_add_iface $SOCK_LOCAL shmif0 $BUS export RUMP_SERVER=$SOCK_LOCAL - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS} atf_check -s exit:0 -o ignore rump.ifconfig shmif0 10.0.0.2/24 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up @@ -68,11 +65,10 @@ setup_local() setup_peer() { - atf_check -s exit:0 ${netserver} ${SOCK_PEER} + rump_server_start $SOCK_PEER + rump_server_add_iface $SOCK_PEER shmif0 $BUS export RUMP_SERVER=$SOCK_PEER - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS} atf_check -s exit:0 -o ignore rump.ifconfig shmif0 10.0.0.1/24 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up @@ -83,16 +79,14 @@ setup_peer() setup_gw() { - atf_check -s exit:0 ${netserver} ${SOCK_GW} + rump_server_start $SOCK_GW + rump_server_add_iface $SOCK_GW shmif0 $BUS + rump_server_add_iface $SOCK_GW shmif1 $BUS2 export RUMP_SERVER=$SOCK_GW - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS} atf_check -s exit:0 -o ignore rump.ifconfig shmif0 10.0.0.254/24 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up - atf_check -s exit:0 -o ignore rump.ifconfig shmif1 create - atf_check -s exit:0 -o ignore rump.ifconfig shmif1 linkstr ${BUS2} atf_check -s exit:0 -o ignore rump.ifconfig shmif1 10.0.2.1/24 atf_check -s exit:0 -o ignore rump.ifconfig shmif1 alias 10.0.2.2/24 atf_check -s exit:0 -o ignore rump.ifconfig shmif1 up @@ -105,39 +99,6 @@ setup_gw() $DEBUG && rump.netstat -rn -f inet } -teardown_gw() -{ - - env RUMP_SERVER=$SOCK_GW rump.halt -} - -check_entry_flags() -{ - local ip=$(echo $1 |sed 's/\./\\./g') - local flags=$2 - - atf_check -s exit:0 -o match:" $flags " -e ignore -x \ - "rump.netstat -rn -f inet | grep ^'$ip'" -} - -check_entry_gw() -{ - local ip=$(echo $1 |sed 's/\./\\./g') - local gw=$2 - - atf_check -s exit:0 -o match:" $gw " -e ignore -x \ - "rump.netstat -rn -f inet | grep ^'$ip'" -} - -check_entry_fail() -{ - local ip=$(echo $1 |sed 's/\./\\./g') - local flags=$2 # Not used currently - - atf_check -s not-exit:0 -e ignore -x \ - "rump.netstat -rn -f inet | grep ^'$ip'" -} - icmp_redirect_timeout_body() { @@ -159,7 +120,7 @@ icmp_redirect_timeout_body() export RUMP_SERVER=$SOCK_PEER atf_check -s exit:0 -o ignore rump.route add -net 10.0.2.0/24 10.0.0.254 # Up, Gateway, Static - check_entry_flags 10.0.2/24 UGS + check_route_flags 10.0.2/24 UGS # # Setup the default gateway to the peer, 10.0.0.1 @@ -167,39 +128,25 @@ icmp_redirect_timeout_body() export RUMP_SERVER=$SOCK_LOCAL atf_check -s exit:0 -o ignore rump.route add default 10.0.0.1 # Up, Gateway, Static - check_entry_flags default UGS + check_route_flags default UGS # Try ping 10.0.2.1 atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 10.0.2.1 $DEBUG && rump.netstat -rn -f inet # Up, Gateway, Host, Dynamic - check_entry_flags 10.0.2.1 UGHD - check_entry_gw 10.0.2.1 10.0.0.254 + check_route_flags 10.0.2.1 UGHD + check_route_gw 10.0.2.1 10.0.0.254 atf_check -s exit:0 sleep $((REDIRECT_TIMEOUT + 2)) # The dynamic entry should be expired and removed - check_entry_fail 10.0.2.1 + check_route_no_entry 10.0.2.1 export RUMP_SERVER=$SOCK_PEER $DEBUG && rump.netstat -rn -f inet - teardown_gw -} - -dump() -{ - - shmif_dumpbus -p - $BUS 2>/dev/null | tcpdump -n -e -r - - gdb -ex bt /usr/bin/rump_server rump_server.core -} - -cleanup() -{ - - env RUMP_SERVER=$SOCK_LOCAL rump.halt - env RUMP_SERVER=$SOCK_PEER rump.halt + rump_server_destroy_ifaces } icmp_redirect_timeout_cleanup() @@ -249,7 +196,7 @@ icmp_redirect_body() export RUMP_SERVER=$SOCK_PEER atf_check -s exit:0 -o ignore rump.route add -net 10.0.2.0/24 10.0.0.254 # Up, Gateway, Static - check_entry_flags 10.0.2/24 UGS + check_route_flags 10.0.2/24 UGS # # Setup the default gateway to the peer, 10.0.0.1 @@ -257,7 +204,7 @@ icmp_redirect_body() export RUMP_SERVER=$SOCK_LOCAL atf_check -s exit:0 -o ignore rump.route add default 10.0.0.1 # Up, Gateway, Static - check_entry_flags default UGS + check_route_flags default UGS ### ICMP redirects are NOT sent by the peer ### @@ -274,7 +221,7 @@ icmp_redirect_body() $DEBUG && rump.netstat -rn -f inet # A direct route shouldn't be created - check_entry_fail 10.0.2.1 + check_route_no_entry 10.0.2.1 ### ICMP redirects are sent by the peer ### @@ -291,8 +238,8 @@ icmp_redirect_body() $DEBUG && rump.netstat -rn -f inet # Up, Gateway, Host, Dynamic - check_entry_flags 10.0.2.1 UGHD - check_entry_gw 10.0.2.1 10.0.0.254 + check_route_flags 10.0.2.1 UGHD + check_route_gw 10.0.2.1 10.0.0.254 export RUMP_SERVER=$SOCK_PEER $DEBUG && rump.netstat -rn -f inet @@ -301,7 +248,7 @@ icmp_redirect_body() # cleanup export RUMP_SERVER=$SOCK_LOCAL atf_check -s exit:0 -o ignore rump.route delete 10.0.2.1 - check_entry_fail 10.0.2.1 + check_route_no_entry 10.0.2.1 ### ICMP redirects are NOT sent by the peer (again) ### @@ -318,10 +265,9 @@ icmp_redirect_body() $DEBUG && rump.netstat -rn -f inet # A direct route shouldn't be created - check_entry_fail 10.0.2.1 - + check_route_no_entry 10.0.2.1 - teardown_gw + rump_server_destroy_ifaces } icmp_redirect_cleanup() diff --git a/contrib/netbsd-tests/net/if/t_compat.c b/contrib/netbsd-tests/net/if/t_compat.c index 4798034..9eb84a3 100644 --- a/contrib/netbsd-tests/net/if/t_compat.c +++ b/contrib/netbsd-tests/net/if/t_compat.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_compat.c,v 1.1 2010/11/07 19:53:42 pooka Exp $ */ +/* $NetBSD: t_compat.c,v 1.4 2016/11/12 15:12:59 kre Exp $ */ #include #include @@ -65,6 +65,8 @@ ATF_TC_BODY(OOSIOCGIFBRDADDR, tc) sprintf(ifreq.ifr_name, "shmif%d", ifnum); netcfg_rump_if(ifreq.ifr_name, "1.7.64.10", "255.255.0.0"); + atf_tc_expect_fail("PR kern/51610: rump does not include COMPAT_43"); + /* query kernel for iface bcast */ RL(fd = rump_sys_socket(AF_INET, SOCK_DGRAM, 0)); RL(rump_sys_ioctl(fd, OOSIOCGIFBRDADDR, &ifreq)); diff --git a/contrib/netbsd-tests/net/if/t_ifconfig.sh b/contrib/netbsd-tests/net/if/t_ifconfig.sh index e8c53e6..a610017 100755 --- a/contrib/netbsd-tests/net/if/t_ifconfig.sh +++ b/contrib/netbsd-tests/net/if/t_ifconfig.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_ifconfig.sh,v 1.11 2016/08/10 22:30:02 kre Exp $ +# $NetBSD: t_ifconfig.sh,v 1.14 2016/10/01 22:15:04 kre Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -34,6 +34,9 @@ RUMP_FLAGS="${RUMP_FLAGS} -lrumpdev" TIMEOUT=3 +anycast="[Aa][Nn][Yy][Cc][Aa][Ss][Tt]" +deprecated="[Dd][Ee][Pp][Rr][Ee][Cc][Aa][Tt][Ee][Dd]" + atf_test_case ifconfig_create_destroy cleanup ifconfig_create_destroy_head() { @@ -227,16 +230,17 @@ ifconfig_parameters_body() rump.ifconfig shmif0 # down, up atf_check -s exit:0 rump.ifconfig shmif0 down - atf_check -s ignore -o ignore -e match:'down' rump.ping -c 1 \ + atf_check -s not-exit:0 -o ignore -e ignore rump.ping -c 1 \ -w $TIMEOUT -n 192.168.0.2 atf_check -s exit:0 rump.ifconfig shmif0 up + atf_check -s exit:0 rump.ifconfig -w 10 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT -n 192.168.0.2 # alias atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.1.1/24 alias - atf_check -s exit:0 -o match:'alias 192.168.1.1' rump.ifconfig shmif0 + atf_check -s exit:0 -o match:'192.168.1.1/24' rump.ifconfig shmif0 atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.1.1/24 -alias - atf_check -s exit:0 -o not-match:'192.168.1.1' rump.ifconfig shmif0 + atf_check -s exit:0 -o not-match:'192.168.1.1/24' rump.ifconfig shmif0 atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::1 atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2 atf_check -s exit:0 -o match:'fc00::1' rump.ifconfig shmif0 inet6 @@ -290,22 +294,22 @@ ifconfig_parameters_body() # anycast atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2 anycast - atf_check -s exit:0 -o match:'fc00::2.+anycast' rump.ifconfig shmif0 inet6 + atf_check -s exit:0 -o match:"fc00::2.+$anycast" rump.ifconfig shmif0 inet6 # deprecated atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::3 deprecated # Not deprecated immediately. Need to wait nd6_timer that does it is scheduled. interval=$(sysctl -n net.inet6.icmp6.nd6_prune) atf_check -s exit:0 sleep $((interval + 1)) - atf_check -s exit:0 -o match:'fc00::3.+deprecated' rump.ifconfig shmif0 inet6 + atf_check -s exit:0 -o match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6 atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::3 -deprecated - atf_check -s exit:0 -o not-match:'fc00::3.+deprecated' rump.ifconfig shmif0 inet6 + atf_check -s exit:0 -o not-match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6 # pltime atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::3 pltime 3 - atf_check -s exit:0 -o not-match:'fc00::3.+deprecated' rump.ifconfig shmif0 inet6 + atf_check -s exit:0 -o not-match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6 atf_check -s exit:0 sleep 5 - atf_check -s exit:0 -o match:'fc00::3.+deprecated' rump.ifconfig shmif0 inet6 + atf_check -s exit:0 -o match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6 # eui64 atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00:1::0 eui64 diff --git a/contrib/netbsd-tests/net/if_bridge/t_bridge.sh b/contrib/netbsd-tests/net/if_bridge/t_bridge.sh index 769893d..25edb35 100755 --- a/contrib/netbsd-tests/net/if_bridge/t_bridge.sh +++ b/contrib/netbsd-tests/net/if_bridge/t_bridge.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_bridge.sh,v 1.13 2016/08/10 22:37:07 kre Exp $ +# $NetBSD: t_bridge.sh,v 1.16 2016/11/25 08:51:16 ozaki-r Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,13 +25,6 @@ # POSSIBILITY OF SUCH DAMAGE. # -libs1="-lrumpnet -lrumpnet_net -lrumpnet_netinet" -libs2="-lrumpnet_bridge -lrumpnet_shmif -lrumpdev" -libs6="-lrumpnet_netinet6" - -inetserver="rump_server ${libs1} ${libs2}" -inet6server="rump_server ${libs1} ${libs6} ${libs2}" - SOCK1=unix://commsock1 SOCK2=unix://commsock2 SOCK3=unix://commsock3 @@ -44,6 +37,7 @@ IPBR2=10.0.0.12 IP6BR1=fc00::11 IP6BR2=fc00::12 +DEBUG=${DEBUG:-false} TIMEOUT=5 atf_test_case bridge_ipv4 cleanup @@ -89,9 +83,8 @@ setup_endpoint() bus=${3} mode=${4} + rump_server_add_iface $sock shmif0 $bus export RUMP_SERVER=${sock} - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${bus} if [ $mode = "ipv6" ]; then atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${addr} else @@ -99,7 +92,7 @@ setup_endpoint() fi atf_check -s exit:0 rump.ifconfig shmif0 up - rump.ifconfig shmif0 + $DEBUG && rump.ifconfig shmif0 } test_endpoint() @@ -118,14 +111,6 @@ test_endpoint() fi } -show_endpoint() -{ - sock=${1} - - export RUMP_SERVER=${sock} - rump.ifconfig -v shmif0 -} - test_setup() { test_endpoint $SOCK1 $IP1 bus1 ipv4 @@ -148,21 +133,20 @@ test_setup6() setup_bridge_server() { + + rump_server_add_iface $SOCK2 shmif0 bus1 + rump_server_add_iface $SOCK2 shmif1 bus2 export RUMP_SERVER=$SOCK2 - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 atf_check -s exit:0 rump.ifconfig shmif0 up - - atf_check -s exit:0 rump.ifconfig shmif1 create - atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus2 atf_check -s exit:0 rump.ifconfig shmif1 up } setup() { - atf_check -s exit:0 ${inetserver} $SOCK1 - atf_check -s exit:0 ${inetserver} $SOCK2 - atf_check -s exit:0 ${inetserver} $SOCK3 + + rump_server_start $SOCK1 bridge + rump_server_start $SOCK2 bridge + rump_server_start $SOCK3 bridge setup_endpoint $SOCK1 $IP1 bus1 ipv4 setup_endpoint $SOCK3 $IP2 bus2 ipv4 @@ -171,9 +155,10 @@ setup() setup6() { - atf_check -s exit:0 ${inet6server} $SOCK1 - atf_check -s exit:0 ${inet6server} $SOCK2 - atf_check -s exit:0 ${inet6server} $SOCK3 + + rump_server_start $SOCK1 netinet6 bridge + rump_server_start $SOCK2 netinet6 bridge + rump_server_start $SOCK3 netinet6 bridge setup_endpoint $SOCK1 $IP61 bus1 ipv6 setup_endpoint $SOCK3 $IP62 bus2 ipv6 @@ -244,19 +229,6 @@ test_setup_bridge() unset LD_PRELOAD } -cleanup() -{ - env RUMP_SERVER=$SOCK1 rump.halt - env RUMP_SERVER=$SOCK2 rump.halt - env RUMP_SERVER=$SOCK3 rump.halt -} - -dump_bus() -{ - /usr/bin/shmif_dumpbus -p - bus1 2>/dev/null| /usr/sbin/tcpdump -n -e -r - - /usr/bin/shmif_dumpbus -p - bus2 2>/dev/null| /usr/sbin/tcpdump -n -e -r - -} - down_up_interfaces() { export RUMP_SERVER=$SOCK1 @@ -360,11 +332,8 @@ test_brconfig_maxaddr() addr1= addr3= n= # Get MAC addresses of the endpoints. - export RUMP_SERVER=$SOCK1 - addr1=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}') - export RUMP_SERVER=$SOCK3 - addr3=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}') - unset RUMP_SERVER + addr1=$(get_macaddr $SOCK1 shmif0) + addr3=$(get_macaddr $SOCK3 shmif0) # Refill the MAC addresses of the endpoints. export RUMP_SERVER=$SOCK1 @@ -422,6 +391,8 @@ bridge_ipv4_body() teardown_bridge test_ping_failure + + rump_server_destroy_ifaces } bridge_ipv6_body() @@ -438,6 +409,8 @@ bridge_ipv6_body() teardown_bridge test_ping6_failure + + rump_server_destroy_ifaces } bridge_rtable_body() @@ -448,16 +421,13 @@ bridge_rtable_body() setup_bridge # Get MAC addresses of the endpoints. - export RUMP_SERVER=$SOCK1 - addr1=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}') - export RUMP_SERVER=$SOCK3 - addr3=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}') - unset RUMP_SERVER + addr1=$(get_macaddr $SOCK1 shmif0) + addr3=$(get_macaddr $SOCK3 shmif0) # Confirm there is no MAC address caches. export RUMP_SERVER=$SOCK2 export LD_PRELOAD=/usr/lib/librumphijack.so - /sbin/brconfig bridge0 + $DEBUG && /sbin/brconfig bridge0 atf_check -s exit:0 -o not-match:"$addr1" /sbin/brconfig bridge0 atf_check -s exit:0 -o not-match:"$addr3" /sbin/brconfig bridge0 unset LD_PRELOAD @@ -470,7 +440,7 @@ bridge_rtable_body() # Tests the addresses are in the cache. export RUMP_SERVER=$SOCK2 export LD_PRELOAD=/usr/lib/librumphijack.so - /sbin/brconfig bridge0 + $DEBUG && /sbin/brconfig bridge0 atf_check -s exit:0 -o match:"$addr1 shmif0" /sbin/brconfig bridge0 atf_check -s exit:0 -o match:"$addr3 shmif1" /sbin/brconfig bridge0 @@ -487,7 +457,7 @@ bridge_rtable_body() unset RUMP_SERVER export RUMP_SERVER=$SOCK2 export LD_PRELOAD=/usr/lib/librumphijack.so - /sbin/brconfig bridge0 + $DEBUG && /sbin/brconfig bridge0 atf_check -s exit:0 -o match:"$addr1 shmif0" /sbin/brconfig bridge0 atf_check -s exit:0 -o match:"$addr3 shmif1" /sbin/brconfig bridge0 @@ -511,6 +481,8 @@ bridge_rtable_body() # TODO: brconfig static/flushall/discover/learn # TODO: cache expiration; it takes 5 minutes at least and we want to # wait here so long. Should we have a sysctl to change the period? + + rump_server_destroy_ifaces } bridge_member_ipv4_body() @@ -531,6 +503,8 @@ bridge_member_ipv4_body() teardown_bridge test_ping_failure + + rump_server_destroy_ifaces } bridge_member_ipv6_body() @@ -550,35 +524,42 @@ bridge_member_ipv6_body() teardown_bridge test_ping6_failure + + rump_server_destroy_ifaces } bridge_ipv4_cleanup() { - dump_bus + + $DEBUG && dump cleanup } bridge_ipv6_cleanup() { - dump_bus + + $DEBUG && dump cleanup } bridge_rtable_cleanup() { - dump_bus + + $DEBUG && dump cleanup } bridge_member_ipv4_cleanup() { - dump_bus + + $DEBUG && dump cleanup } bridge_member_ipv6_cleanup() { - dump_bus + + $DEBUG && dump cleanup } diff --git a/contrib/netbsd-tests/net/if_gif/t_gif.sh b/contrib/netbsd-tests/net/if_gif/t_gif.sh index b804d7b..8690d78 100755 --- a/contrib/netbsd-tests/net/if_gif/t_gif.sh +++ b/contrib/netbsd-tests/net/if_gif/t_gif.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_gif.sh,v 1.5 2016/08/10 08:29:20 ozaki-r Exp $ +# $NetBSD: t_gif.sh,v 1.9 2016/12/21 09:46:39 ozaki-r Exp $ # # Copyright (c) 2015 Internet Initiative Japan Inc. # All rights reserved. @@ -25,10 +25,6 @@ # POSSIBILITY OF SUCH DAMAGE. # -server="rump_server -v -lrumpdev -lrumpnet -lrumpnet_net -lrumpnet_netinet \ - -lrumpnet_netinet6 -lrumpnet_shmif -lrumpnet_gif" -HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes" - SOCK1=unix://commsock1 # for ROUTER1 SOCK2=unix://commsock2 # for ROUTER2 ROUTER1_LANIP=192.168.1.1 @@ -65,6 +61,7 @@ ROUTER2_GIFIP6_DUMMY=fc00:14::1 ROUTER2_GIFIP6_RECURSIVE1=fc00:104::1 ROUTER2_GIFIP6_RECURSIVE2=fc00:204::1 +DEBUG=${DEBUG:-true} TIMEOUT=5 setup_router() @@ -75,9 +72,10 @@ setup_router() wan=${4} wan_mode=${5} + rump_server_add_iface $sock shmif0 bus0 + rump_server_add_iface $sock shmif1 bus1 + export RUMP_SERVER=${sock} - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus0 if [ ${lan_mode} = "ipv6" ]; then atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${lan} else @@ -86,8 +84,6 @@ setup_router() atf_check -s exit:0 rump.ifconfig shmif0 up rump.ifconfig shmif0 - atf_check -s exit:0 rump.ifconfig shmif1 create - atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus1 if [ ${wan_mode} = "ipv6" ]; then atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${wan} else @@ -126,8 +122,8 @@ setup() inner=${1} outer=${2} - atf_check -s exit:0 ${server} $SOCK1 - atf_check -s exit:0 ${server} $SOCK2 + rump_server_start $SOCK1 netinet6 gif + rump_server_start $SOCK2 netinet6 gif router1_lan="" router1_lan_mode="" @@ -482,18 +478,6 @@ teardown_recursive_tunnels() atf_check -s exit:0 rump.ifconfig gif2 destroy } -cleanup() -{ - env RUMP_SERVER=$SOCK1 rump.halt - env RUMP_SERVER=$SOCK2 rump.halt -} - -dump_bus() -{ - /usr/bin/shmif_dumpbus -p - bus0 2>/dev/null| /usr/sbin/tcpdump -n -e -r - - /usr/bin/shmif_dumpbus -p - bus1 2>/dev/null| /usr/sbin/tcpdump -n -e -r - -} - test_ping_failure() { mode=$1 @@ -739,7 +723,7 @@ add_test() inner=$3 outer=$4 - name="${category}${inner}over${outer}" + name="gif_${category}_${inner}over${outer}" fulldesc="Does ${inner} over ${outer} if_gif ${desc}" atf_test_case ${name} cleanup @@ -751,9 +735,10 @@ add_test() ${category}_setup ${inner} ${outer}; \ ${category}_test ${inner} ${outer}; \ ${category}_teardown ${inner} ${outer}; \ + rump_server_destroy_ifaces; \ }; \ ${name}_cleanup() { \ - dump_bus; \ + $DEBUG && dump; \ cleanup; \ }" atf_add_test_case ${name} diff --git a/contrib/netbsd-tests/net/if_pppoe/t_pppoe.sh b/contrib/netbsd-tests/net/if_pppoe/t_pppoe.sh index 3199ca0..8d9d5c2 100755 --- a/contrib/netbsd-tests/net/if_pppoe/t_pppoe.sh +++ b/contrib/netbsd-tests/net/if_pppoe/t_pppoe.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_pppoe.sh,v 1.2 2016/08/07 23:34:31 pgoyette Exp $ +# $NetBSD: t_pppoe.sh,v 1.16 2016/12/14 03:30:30 knakahara Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -28,6 +28,7 @@ server="rump_server -lrump -lrumpnet -lrumpnet_net -lrumpnet_netinet \ -lrumpnet_netinet6 -lrumpnet_shmif -lrumpdev \ -lrumpnet_pppoe" +# pppoectl doesn't work with RUMPHIJACK=sysctl=yes HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so" SERVER=unix://commsock1 @@ -35,17 +36,23 @@ CLIENT=unix://commsock2 SERVER_IP=10.3.3.1 CLIENT_IP=10.3.3.3 +SERVER_IP6=fc00::1 +CLIENT_IP6=fc00::3 AUTHNAME=foobar@baz.com SECRET=oink BUS=bus0 TIMEOUT=3 -WAITTIME=5 -DEBUG=false - -atf_test_case pap cleanup +WAITTIME=10 +DEBUG=${DEBUG:-false} setup() { + inet=true + + if [ $# -ne 0 ]; then + eval $@ + fi + atf_check -s exit:0 ${server} $SERVER atf_check -s exit:0 ${server} $CLIENT @@ -55,7 +62,8 @@ setup() atf_check -s exit:0 rump.ifconfig shmif0 up atf_check -s exit:0 rump.ifconfig pppoe0 create - atf_check -s exit:0 rump.ifconfig pppoe0 inet $SERVER_IP $CLIENT_IP down + $inet && atf_check -s exit:0 rump.ifconfig pppoe0 \ + inet $SERVER_IP $CLIENT_IP down atf_check -s exit:0 rump.ifconfig pppoe0 link0 $DEBUG && rump.ifconfig @@ -70,22 +78,19 @@ setup() atf_check -s exit:0 rump.ifconfig shmif0 up atf_check -s exit:0 rump.ifconfig pppoe0 create - atf_check -s exit:0 rump.ifconfig pppoe0 inet 0.0.0.0 0.0.0.1 down + $inet && atf_check -s exit:0 rump.ifconfig pppoe0 \ + inet 0.0.0.0 0.0.0.1 down atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 pppoe0" unset RUMP_SERVER } + cleanup() { env RUMP_SERVER=$SERVER rump.halt env RUMP_SERVER=$CLIENT rump.halt } -pap_head() -{ - atf_set "descr" "Does simple pap tests" - atf_set "require.progs" "rump_server pppoectl" -} wait_for_session_established() { @@ -98,21 +103,50 @@ wait_for_session_established() sleep 1 done - if [ $dontfail != "dontfail" ]; then + if [ "$dontfail" != "dontfail" ]; then atf_fail "Couldn't connect to the server for $n seconds." fi } -pap_body() +wait_for_disconnected() +{ + local dontfail=$1 + local n=$WAITTIME + + for i in $(seq $n); do + $HIJACKING pppoectl -d pppoe0 | grep -q "state = initial" + [ $? = 0 ] && return + # If PPPoE client is disconnected by PPPoE server and then + # the client kicks callout of pppoe_timeout(), the client + # state is changed to PPPOE_STATE_PADI_SENT while padi retrying. + $HIJACKING pppoectl -d pppoe0 | grep -q "state = PADI sent" + [ $? = 0 ] && return + + sleep 1 + done + + if [ "$dontfail" != "dontfail" ]; then + atf_fail "Couldn't disconnect for $n seconds." + fi +} + +run_test() { - local auth=pap + local auth=$1 setup + # As pppoe client doesn't support rechallenge yet. + local server_optparam="" + if [ $auth = "chap" ]; then + server_optparam="norechallenge" + fi + export RUMP_SERVER=$SERVER local setup_serverparam="pppoectl pppoe0 hisauthproto=$auth \ 'hisauthname=$AUTHNAME' \ 'hisauthsecret=$SECRET' \ - 'myauthproto=none'" + 'myauthproto=none' \ + $server_optparam" atf_check -s exit:0 -x "$HIJACKING $setup_serverparam" atf_check -s exit:0 rump.ifconfig pppoe0 up unset RUMP_SERVER @@ -130,8 +164,11 @@ pap_body() unset RUMP_SERVER # test for disconnection from server - atf_check -s exit:0 -x "env RUMP_SERVER=$SERVER rump.ifconfig pppoe0 down" + export RUMP_SERVER=$SERVER + atf_check -s exit:0 rump.ifconfig pppoe0 down + wait_for_disconnected export RUMP_SERVER=$CLIENT + wait_for_disconnected atf_check -s not-exit:0 -o ignore -e ignore \ rump.ping -c 1 -w $TIMEOUT $SERVER_IP atf_check -s exit:0 -o match:'PADI sent' -x "$HIJACKING pppoectl -d pppoe0" @@ -145,15 +182,18 @@ pap_body() unset RUMP_SERVER # test for disconnection from client - atf_check -s exit:0 -x "env RUMP_SERVER=$CLIENT rump.ifconfig pppoe0 down" + export RUMP_SERVER=$CLIENT + atf_check -s exit:0 -x rump.ifconfig pppoe0 down + wait_for_disconnected export RUMP_SERVER=$SERVER + wait_for_disconnected $DEBUG && $HIJACKING pppoectl -d pppoe0 atf_check -s not-exit:0 -o ignore -e ignore \ rump.ping -c 1 -w $TIMEOUT $CLIENT_IP atf_check -s exit:0 -o match:'initial' -x "$HIJACKING pppoectl -d pppoe0" unset RUMP_SERVER - # test for recconecting + # test for reconnecting export RUMP_SERVER=$CLIENT atf_check -s exit:0 -x rump.ifconfig pppoe0 up wait_for_session_established @@ -162,6 +202,7 @@ pap_body() unset RUMP_SERVER export RUMP_SERVER=$SERVER + atf_check -s exit:0 rump.ifconfig -w 10 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $CLIENT_IP atf_check -s exit:0 -o match:'session' -x "$HIJACKING pppoectl -d pppoe0" $DEBUG && HIJACKING pppoectl -d pppoe0 @@ -170,6 +211,7 @@ pap_body() # test for invalid password export RUMP_SERVER=$CLIENT atf_check -s exit:0 rump.ifconfig pppoe0 down + wait_for_disconnected local setup_clientparam="pppoectl pppoe0 myauthproto=$auth \ 'myauthname=$AUTHNAME' \ 'myauthsecret=invalidsecret' \ @@ -179,15 +221,196 @@ pap_body() wait_for_session_established dontfail atf_check -s not-exit:0 -o ignore -e ignore \ rump.ping -c 1 -w $TIMEOUT $SERVER_IP + atf_check -s exit:0 -o match:'DETACHED' rump.ifconfig pppoe0 + unset RUMP_SERVER +} + +atf_test_case pppoe_pap cleanup + +pppoe_pap_head() +{ + atf_set "descr" "Does simple pap tests" + atf_set "require.progs" "rump_server pppoectl" +} + +pppoe_pap_body() +{ + run_test pap +} + +pppoe_pap_cleanup() +{ + cleanup +} + +atf_test_case pppoe_chap cleanup + +pppoe_chap_head() +{ + atf_set "descr" "Does simple chap tests" + atf_set "require.progs" "rump_server pppoectl" +} + +pppoe_chap_body() +{ + run_test chap +} + +pppoe_chap_cleanup() +{ + cleanup +} + +run_test6() +{ + local auth=$1 + setup "inet=false" + + # As pppoe client doesn't support rechallenge yet. + local server_optparam="" + if [ $auth = "chap" ]; then + server_optparam="norechallenge" + fi + + export RUMP_SERVER=$SERVER + local setup_serverparam="pppoectl pppoe0 hisauthproto=$auth \ + 'hisauthname=$AUTHNAME' \ + 'hisauthsecret=$SECRET' \ + 'myauthproto=none' \ + $server_optparam" + atf_check -s exit:0 -x "$HIJACKING $setup_serverparam" + atf_check -s exit:0 rump.ifconfig pppoe0 inet6 $SERVER_IP6/64 down + atf_check -s exit:0 rump.ifconfig pppoe0 up + unset RUMP_SERVER + + export RUMP_SERVER=$CLIENT + local setup_clientparam="pppoectl pppoe0 myauthproto=$auth \ + 'myauthname=$AUTHNAME' \ + 'myauthsecret=$SECRET' \ + 'hisauthproto=none'" + atf_check -s exit:0 -x "$HIJACKING $setup_clientparam" + atf_check -s exit:0 rump.ifconfig pppoe0 inet6 $CLIENT_IP6/64 down + atf_check -s exit:0 rump.ifconfig pppoe0 up + $DEBUG && rump.ifconfig + wait_for_session_established + atf_check -s exit:0 -o ignore rump.ifconfig -w 10 + export RUMP_SERVER=$SERVER + atf_check -s exit:0 -o ignore rump.ifconfig -w 10 + export RUMP_SERVER=$CLIENT + atf_check -s exit:0 -o ignore rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6 + unset RUMP_SERVER + + # test for disconnection from server + export RUMP_SERVER=$SERVER + session_id=`$HIJACKING pppoectl -d pppoe0 | grep state` + atf_check -s exit:0 rump.ifconfig pppoe0 down + wait_for_disconnected + export RUMP_SERVER=$CLIENT + wait_for_disconnected + atf_check -s not-exit:0 -o ignore -e ignore \ + rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6 + atf_check -s exit:0 -o not-match:"$session_id" -x "$HIJACKING pppoectl -d pppoe0" + unset RUMP_SERVER + + # test for recoonecting + export RUMP_SERVER=$SERVER + atf_check -s exit:0 rump.ifconfig pppoe0 up + wait_for_session_established + atf_check -s exit:0 rump.ifconfig -w 10 + $DEBUG && $HIJACKING pppoectl -d pppoe0 + $DEBUG && rump.ifconfig pppoe0 + export RUMP_SERVER=$CLIENT + atf_check -s exit:0 -o ignore rump.ifconfig -w 10 + atf_check -s exit:0 -o ignore rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6 + unset RUMP_SERVER + + # test for disconnection from client + export RUMP_SERVER=$CLIENT + atf_check -s exit:0 rump.ifconfig pppoe0 down + wait_for_disconnected + + export RUMP_SERVER=$SERVER + wait_for_disconnected + $DEBUG && $HIJACKING pppoectl -d pppoe0 + atf_check -s not-exit:0 -o ignore -e ignore \ + rump.ping6 -c 1 -X $TIMEOUT $CLIENT_IP6 atf_check -s exit:0 -o match:'initial' -x "$HIJACKING pppoectl -d pppoe0" unset RUMP_SERVER + + # test for reconnecting + export RUMP_SERVER=$CLIENT + atf_check -s exit:0 rump.ifconfig pppoe0 up + wait_for_session_established + atf_check -s exit:0 rump.ifconfig -w 10 + + $DEBUG && rump.ifconfig pppoe0 + $DEBUG && $HIJACKING pppoectl -d pppoe0 + unset RUMP_SERVER + + export RUMP_SERVER=$SERVER + atf_check -s exit:0 rump.ifconfig -w 10 + atf_check -s exit:0 -o ignore rump.ping6 -c 1 -X $TIMEOUT $CLIENT_IP6 + atf_check -s exit:0 -o match:'session' -x "$HIJACKING pppoectl -d pppoe0" + $DEBUG && HIJACKING pppoectl -d pppoe0 + unset RUMP_SERVER + + # test for invalid password + export RUMP_SERVER=$CLIENT + atf_check -s exit:0 rump.ifconfig pppoe0 down + wait_for_disconnected + local setup_clientparam="pppoectl pppoe0 myauthproto=$auth \ + 'myauthname=$AUTHNAME' \ + 'myauthsecret=invalidsecret' \ + 'hisauthproto=none'" + atf_check -s exit:0 -x "$HIJACKING $setup_clientparam" + atf_check -s exit:0 rump.ifconfig pppoe0 up + wait_for_session_established dontfail + atf_check -s not-exit:0 -o ignore -e ignore \ + rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6 + atf_check -s exit:0 -o match:'DETACHED' rump.ifconfig pppoe0 + unset RUMP_SERVER } -pap_cleanup() +atf_test_case pppoe6_pap cleanup + +pppoe6_pap_head() +{ + atf_set "descr" "Does simple pap using IPv6 tests" + atf_set "require.progs" "rump_server pppoectl" +} + +pppoe6_pap_body() +{ + run_test6 pap +} + +pppoe6_pap_cleanup() +{ + cleanup +} + +atf_test_case pppoe6_chap cleanup + +pppoe6_chap_head() +{ + atf_set "descr" "Does simple chap using IPv6 tests" + atf_set "require.progs" "rump_server pppoectl" +} + +pppoe6_chap_body() +{ + run_test6 chap +} + +pppoe6_chap_cleanup() { cleanup } + atf_init_test_cases() { - atf_add_test_case pap + atf_add_test_case pppoe_pap + atf_add_test_case pppoe_chap + atf_add_test_case pppoe6_pap + atf_add_test_case pppoe6_chap } diff --git a/contrib/netbsd-tests/net/if_tap/t_tap.sh b/contrib/netbsd-tests/net/if_tap/t_tap.sh index 29efc20..4b1ce25 100755 --- a/contrib/netbsd-tests/net/if_tap/t_tap.sh +++ b/contrib/netbsd-tests/net/if_tap/t_tap.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_tap.sh,v 1.3 2016/08/10 22:42:21 kre Exp $ +# $NetBSD: t_tap.sh,v 1.6 2016/11/25 08:51:16 ozaki-r Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -25,10 +25,6 @@ # POSSIBILITY OF SUCH DAMAGE. # -RUMP_FLAGS="-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6" -RUMP_FLAGS="$RUMP_FLAGS -lrumpnet_shmif -lrumpnet_tap -lrumpnet_bridge -lrumpdev" -HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes" - SOCK_LOCAL=unix://commsock1 SOCK_REMOTE=unix://commsock2 BUS=bus1 @@ -39,7 +35,7 @@ IP6_LOCAL=fc00::1 IP6_TAP=fc00::2 IP6_REMOTE=fc00::3 -DEBUG=false +DEBUG=${DEBUG:-false} TIMEOUT=1 atf_test_case tap_create_destroy cleanup @@ -53,7 +49,7 @@ tap_create_destroy_head() tap_create_destroy_body() { - atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL} + rump_server_start $SOCK_LOCAL netinet6 tap export RUMP_SERVER=${SOCK_LOCAL} @@ -77,7 +73,8 @@ tap_create_destroy_body() tap_create_destroy_cleanup() { - RUMP_SERVER=${SOCK_LOCAL} rump.halt + $DEBUG && dump + cleanup } atf_test_case tap_stand_alone cleanup @@ -90,13 +87,14 @@ tap_create_destroy_head() tap_stand_alone_body() { - atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL} - atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_REMOTE} - export RUMP_SERVER=${SOCK_LOCAL} + rump_server_start $SOCK_LOCAL netinet6 tap + rump_server_start $SOCK_REMOTE netinet6 tap - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS + rump_server_add_iface $SOCK_LOCAL shmif0 $BUS + rump_server_add_iface $SOCK_REMOTE shmif0 $BUS + + export RUMP_SERVER=${SOCK_LOCAL} atf_check -s exit:0 rump.ifconfig shmif0 $IP4_LOCAL atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_LOCAL atf_check -s exit:0 rump.ifconfig shmif0 up @@ -108,8 +106,6 @@ tap_stand_alone_body() export RUMP_SERVER=${SOCK_REMOTE} - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS atf_check -s exit:0 rump.ifconfig shmif0 $IP4_REMOTE atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_REMOTE atf_check -s exit:0 rump.ifconfig shmif0 up @@ -124,13 +120,15 @@ tap_stand_alone_body() # Cannot reach to an alone tap atf_check -s not-exit:0 -o ignore -e ignore \ rump.ping6 -n -X $TIMEOUT -c 1 $IP6_TAP + + rump_server_destroy_ifaces } tap_stand_alone_cleanup() { - RUMP_SERVER=${SOCK_LOCAL} rump.halt - RUMP_SERVER=${SOCK_REMOTE} rump.halt + $DEBUG && dump + cleanup } atf_test_case tap_bridged cleanup @@ -143,13 +141,15 @@ tap_bridged_head() tap_bridged_body() { - atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL} - atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_REMOTE} + + rump_server_start $SOCK_LOCAL netinet6 tap bridge + rump_server_start $SOCK_REMOTE netinet6 tap + + rump_server_add_iface $SOCK_LOCAL shmif0 $BUS + rump_server_add_iface $SOCK_REMOTE shmif0 $BUS export RUMP_SERVER=${SOCK_LOCAL} - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS atf_check -s exit:0 rump.ifconfig shmif0 $IP4_LOCAL atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_LOCAL atf_check -s exit:0 rump.ifconfig shmif0 up @@ -168,8 +168,6 @@ tap_bridged_body() export RUMP_SERVER=${SOCK_REMOTE} - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS atf_check -s exit:0 rump.ifconfig shmif0 $IP4_REMOTE atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_REMOTE atf_check -s exit:0 rump.ifconfig shmif0 up @@ -180,13 +178,15 @@ tap_bridged_body() atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_LOCAL atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_TAP + + rump_server_destroy_ifaces } tap_bridged_cleanup() { - RUMP_SERVER=${SOCK_LOCAL} rump.halt - RUMP_SERVER=${SOCK_REMOTE} rump.halt + $DEBUG && dump + cleanup } atf_init_test_cases() diff --git a/contrib/netbsd-tests/net/mcast/t_mcast.sh b/contrib/netbsd-tests/net/mcast/t_mcast.sh index 67e13d4..aeb7000 100755 --- a/contrib/netbsd-tests/net/mcast/t_mcast.sh +++ b/contrib/netbsd-tests/net/mcast/t_mcast.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_mcast.sh,v 1.2 2016/08/10 22:45:39 kre Exp $ +# $NetBSD: t_mcast.sh,v 1.4 2016/11/25 08:51:16 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,12 +25,9 @@ # POSSIBILITY OF SUCH DAMAGE. # -netserver="rump_server -lrumpnet -lrumpnet_net" -netserver="$netserver -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_shmif" -netserver="$netserver -lrumpdev" export RUMP_SERVER=unix://commsock -DEBUG=false +DEBUG=${DEBUG:-false} run_test() { @@ -38,9 +35,8 @@ run_test() local opts="$2" local mcast="$(atf_get_srcdir)/mcast" - atf_check -s exit:0 ${netserver} ${RUMP_SERVER} - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 + rump_server_start $RUMP_SERVER netinet6 + rump_server_add_iface $RUMP_SERVER shmif0 bus1 atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.2/24 atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2/64 atf_check -s exit:0 rump.ifconfig shmif0 up @@ -79,11 +75,11 @@ add_test() }; \ mcast_${name}_body() { \ run_test \"${name}\" \"${opts}\"; \ + rump_server_destroy_ifaces; \ }; \ mcast_${name}_cleanup() { \ - ${DEBUG} && /usr/bin/shmif_dumpbus -p - bus1 2>/dev/null | \ - /usr/sbin/tcpdump -n -e -r -; \ - env RUMP_SERVER=unix://commsock rump.halt; \ + ${DEBUG} && dump; \ + cleanup; \ }" atf_add_test_case "mcast_${name}" } diff --git a/contrib/netbsd-tests/net/ndp/t_dad.sh b/contrib/netbsd-tests/net/ndp/t_dad.sh index 98b8ae0..50ec933 100755 --- a/contrib/netbsd-tests/net/ndp/t_dad.sh +++ b/contrib/netbsd-tests/net/ndp/t_dad.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_dad.sh,v 1.5 2016/08/10 23:07:57 kre Exp $ +# $NetBSD: t_dad.sh,v 1.12 2016/11/25 08:51:17 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,18 +25,16 @@ # POSSIBILITY OF SUCH DAMAGE. # -inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet" -inetserver="$inetserver -lrumpnet_netinet6 -lrumpnet_shmif" -inetserver="$inetserver -lrumpdev" -HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes" - SOCKLOCAL=unix://commsock1 SOCKPEER=unix://commsock2 -DEBUG=false +DEBUG=${DEBUG:-false} + +duplicated="[Dd][Uu][Pp][Ll][Ii][Cc][Aa][Tt][Ee][Dd]" atf_test_case dad_basic cleanup atf_test_case dad_duplicated cleanup +atf_test_case dad_count cleanup dad_basic_head() { @@ -50,15 +48,20 @@ dad_duplicated_head() atf_set "require.progs" "rump_server" } +dad_count_head() +{ + atf_set "descr" "Tests for IPv6 DAD count behavior" + atf_set "require.progs" "rump_server" +} + setup_server() { local sock=$1 local ip=$2 - export RUMP_SERVER=$sock + rump_server_add_iface $sock shmif0 bus1 - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 + export RUMP_SERVER=$sock atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip atf_check -s exit:0 rump.ifconfig shmif0 up atf_check -s exit:0 rump.ifconfig -w 10 @@ -76,21 +79,6 @@ make_ns_pkt_str() echo $pkt } -extract_new_packets() -{ - local old=./old - - if [ ! -f $old ]; then - old=/dev/null - fi - - shmif_dumpbus -p - bus1 2>/dev/null| \ - tcpdump -n -e -r - 2>/dev/null > ./new - diff -u $old ./new |grep '^+' |cut -d '+' -f 2 > ./diff - mv -f ./new ./old - cat ./diff -} - dad_basic_body() { local pkt= @@ -98,11 +86,10 @@ dad_basic_body() local localip2=fc00::2 local localip3=fc00::3 - atf_check -s exit:0 ${inetserver} $SOCKLOCAL - export RUMP_SERVER=$SOCKLOCAL + rump_server_start $SOCKLOCAL netinet6 + rump_server_add_iface $SOCKLOCAL shmif0 bus1 - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 + export RUMP_SERVER=$SOCKLOCAL atf_check -s exit:0 rump.ifconfig shmif0 inet6 $localip1 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $localip2 $DEBUG && rump.ifconfig shmif0 @@ -118,7 +105,7 @@ dad_basic_body() #atf_check -s exit:0 -x "cat ./out |grep $localip2 |grep -q tentative" atf_check -s exit:0 sleep 2 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out # Check DAD probe packets (Neighbor Solicitation Message) @@ -130,7 +117,7 @@ dad_basic_body() # Waiting for DAD complete atf_check -s exit:0 rump.ifconfig -w 10 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out # IPv6 DAD doesn't announce (Neighbor Advertisement Message) @@ -149,20 +136,22 @@ dad_basic_body() # Check DAD probe packets (Neighbor Solicitation Message) atf_check -s exit:0 sleep 2 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out pkt=$(make_ns_pkt_str 3 $localip3) atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" # Waiting for DAD complete atf_check -s exit:0 rump.ifconfig -w 10 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out # IPv6 DAD doesn't announce (Neighbor Advertisement Message) # The new address left tentative atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip3 |grep -q tentative" + + rump_server_destroy_ifaces } dad_duplicated_body() @@ -171,8 +160,8 @@ dad_duplicated_body() local localip2=fc00::11 local peerip=fc00::2 - atf_check -s exit:0 ${inetserver} $SOCKLOCAL - atf_check -s exit:0 ${inetserver} $SOCKPEER + rump_server_start $SOCKLOCAL netinet6 + rump_server_start $SOCKPEER netinet6 setup_server $SOCKLOCAL $localip1 setup_server $SOCKPEER $peerip @@ -180,7 +169,8 @@ dad_duplicated_body() export RUMP_SERVER=$SOCKLOCAL # The primary address isn't marked as duplicated - atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip1 |grep -q duplicated" + atf_check -s exit:0 -o not-match:"$localip1.+$duplicated" \ + rump.ifconfig shmif0 # # Add a new address duplicated with the peer server @@ -189,52 +179,81 @@ dad_duplicated_body() atf_check -s exit:0 sleep 1 # The new address is marked as duplicated - atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep $peerip |grep -q duplicated" + atf_check -s exit:0 -o match:"$peerip.+$duplicated" \ + rump.ifconfig shmif0 # A unique address isn't marked as duplicated atf_check -s exit:0 rump.ifconfig shmif0 inet6 $localip2 atf_check -s exit:0 sleep 1 - atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip2 |grep -q duplicated" + atf_check -s exit:0 -o not-match:"$localip2.+$duplicated" \ + rump.ifconfig shmif0 + + rump_server_destroy_ifaces } -cleanup() +dad_count_test() { - gdb -ex bt /usr/bin/rump_server rump_server.core - gdb -ex bt /usr/sbin/arp arp.core - env RUMP_SERVER=$SOCKLOCAL rump.halt - env RUMP_SERVER=$SOCKPEER rump.halt + local pkt= + local count=$1 + local id=$2 + local target=$3 + + # + # Set DAD count to $count + # + atf_check -s exit:0 rump.sysctl -w -q net.inet6.ip6.dad_count=$count + + # Add a new address + atf_check -s exit:0 rump.ifconfig shmif0 inet6 $target + + # Waiting for DAD complete + atf_check -s exit:0 rump.ifconfig -w 20 + + # Check the number of DAD probe packets (Neighbor Solicitation Message) + atf_check -s exit:0 sleep 2 + extract_new_packets bus1 > ./out + $DEBUG && cat ./out + pkt=$(make_ns_pkt_str $id $target) + atf_check -s exit:0 -o match:"$count" \ + -x "cat ./out |grep '$pkt' | wc -l | tr -d ' '" } -dump_local() +dad_count_body() { + local localip1=fc00::1 + local localip2=fc00::2 + + rump_server_start $SOCKLOCAL netinet6 + rump_server_add_iface $SOCKLOCAL shmif0 bus1 + export RUMP_SERVER=$SOCKLOCAL - rump.netstat -nr - rump.arp -n -a - rump.ifconfig - $HIJACKING dmesg -} -dump_peer() -{ - export RUMP_SERVER=$SOCKPEER - rump.netstat -nr - rump.arp -n -a - rump.ifconfig - $HIJACKING dmesg -} + # Check default value + atf_check -s exit:0 -o match:"1" rump.sysctl -n net.inet6.ip6.dad_count -dump() -{ - dump_local - dump_peer - shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - + # Setup interface + atf_check -s exit:0 rump.ifconfig shmif0 up + atf_check -s exit:0 sleep 2 + rump.ifconfig shmif0 > ./out + $DEBUG && cat ./out + + # + # Set and test DAD count (count=1) + # + dad_count_test 1 1 $localip1 + + # + # Set and test DAD count (count=8) + # + dad_count_test 8 2 $localip2 + + rump_server_destroy_ifaces } dad_basic_cleanup() { - $DEBUG && dump_local - $DEBUG && shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - - env RUMP_SERVER=$SOCKLOCAL rump.halt + $DEBUG && dump + cleanup } dad_duplicated_cleanup() @@ -243,8 +262,15 @@ dad_duplicated_cleanup() cleanup } +dad_count_cleanup() +{ + $DEBUG && dump + cleanup +} + atf_init_test_cases() { atf_add_test_case dad_basic atf_add_test_case dad_duplicated + atf_add_test_case dad_count } diff --git a/contrib/netbsd-tests/net/ndp/t_ndp.sh b/contrib/netbsd-tests/net/ndp/t_ndp.sh index 4491981..aa96390 100755 --- a/contrib/netbsd-tests/net/ndp/t_ndp.sh +++ b/contrib/netbsd-tests/net/ndp/t_ndp.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_ndp.sh,v 1.13 2016/08/10 23:07:57 kre Exp $ +# $NetBSD: t_ndp.sh,v 1.17 2016/11/25 08:51:17 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,17 +25,12 @@ # POSSIBILITY OF SUCH DAMAGE. # -inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet" -inetserver="$inetserver -lrumpnet_netinet6 -lrumpnet_shmif" -inetserver="$inetserver -lrumpdev" -HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes" - SOCKSRC=unix://commsock1 SOCKDST=unix://commsock2 IP6SRC=fc00::1 IP6DST=fc00::2 -DEBUG=true +DEBUG=${DEBUG:-true} TIMEOUT=1 atf_test_case ndp_cache_expiration cleanup @@ -78,9 +73,8 @@ setup_dst_server() { local assign_ip=$1 + rump_server_add_iface $SOCKDST shmif0 bus1 export RUMP_SERVER=$SOCKDST - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 if [ "$assign_ip" != no ]; then atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6DST fi @@ -97,8 +91,7 @@ setup_src_server() export RUMP_SERVER=$SOCKSRC # Setup an interface - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 + rump_server_add_iface $SOCKSRC shmif0 bus1 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6SRC atf_check -s exit:0 rump.ifconfig shmif0 up atf_check -s exit:0 rump.ifconfig -w 10 @@ -119,8 +112,9 @@ get_timeout() ndp_cache_expiration_body() { - atf_check -s exit:0 ${inetserver} $SOCKSRC - atf_check -s exit:0 ${inetserver} $SOCKDST + + rump_server_start $SOCKSRC netinet6 + rump_server_start $SOCKDST netinet6 setup_dst_server setup_src_server @@ -144,6 +138,8 @@ ndp_cache_expiration_body() atf_check -s exit:0 -o match:'permanent' rump.ndp -n $IP6SRC # Expired but remains until GC sweaps it (1 day) atf_check -s exit:0 -o match:'(1d0h0m|23h59m)' rump.ndp -n $IP6DST + + rump_server_destroy_ifaces } ifdown_dst_server() @@ -155,8 +151,9 @@ ifdown_dst_server() ndp_commands_body() { - atf_check -s exit:0 ${inetserver} $SOCKSRC - atf_check -s exit:0 ${inetserver} $SOCKDST + + rump_server_start $SOCKSRC netinet6 + rump_server_start $SOCKDST netinet6 setup_dst_server setup_src_server @@ -217,13 +214,14 @@ ndp_commands_body() $DEBUG && rump.ndp -n -a atf_check -s exit:0 -o not-match:'permanent' rump.ndp -n fc00::10 - return 0 + rump_server_destroy_ifaces } ndp_cache_overwriting_body() { - atf_check -s exit:0 ${inetserver} $SOCKSRC - atf_check -s exit:0 ${inetserver} $SOCKDST + + rump_server_start $SOCKSRC netinet6 + rump_server_start $SOCKDST netinet6 setup_dst_server setup_src_server @@ -249,7 +247,7 @@ ndp_cache_overwriting_body() #atf_check -s not-exit:0 -e ignore rump.ndp -s fc00::10 b2:a0:20:00:00:ff #$DEBUG && rump.ndp -n -a - return 0 + rump_server_destroy_ifaces } get_n_caches() @@ -261,8 +259,8 @@ get_n_caches() ndp_neighborgcthresh_body() { - atf_check -s exit:0 ${inetserver} $SOCKSRC - atf_check -s exit:0 ${inetserver} $SOCKDST + rump_server_start $SOCKSRC netinet6 + rump_server_start $SOCKDST netinet6 setup_dst_server no setup_src_server @@ -311,7 +309,7 @@ ndp_neighborgcthresh_body() atf_fail "Neighbor caches are not GC-ed" fi - return 0 + rump_server_destroy_ifaces } make_pkt_str_na() @@ -324,33 +322,18 @@ make_pkt_str_na() echo $pkt } -extract_new_packets() -{ - local old=./old - - if [ ! -f $old ]; then - old=/dev/null - fi - - shmif_dumpbus -p - bus1 2>/dev/null| \ - tcpdump -n -e -r - 2>/dev/null > ./new - diff -u $old ./new |grep '^+' |cut -d '+' -f 2 > ./diff - mv -f ./new ./old - cat ./diff -} - ndp_link_activation_body() { local linklocal= - atf_check -s exit:0 ${inetserver} $SOCKSRC - atf_check -s exit:0 ${inetserver} $SOCKDST + rump_server_start $SOCKSRC netinet6 + rump_server_start $SOCKDST netinet6 setup_dst_server setup_src_server # flush old packets - extract_new_packets > ./out + extract_new_packets bus1 > ./out export RUMP_SERVER=$SOCKSRC @@ -358,7 +341,7 @@ ndp_link_activation_body() b2:a1:00:00:00:01 atf_check -s exit:0 sleep 1 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out linklocal=$(rump.ifconfig shmif0 |awk '/fe80/ {print $2;}' |awk -F % '{print $1;}') @@ -371,7 +354,7 @@ ndp_link_activation_body() b2:a1:00:00:00:02 active atf_check -s exit:0 sleep 1 - extract_new_packets > ./out + extract_new_packets bus1 > ./out $DEBUG && cat ./out linklocal=$(rump.ifconfig shmif0 |awk '/fe80/ {print $2;}' |awk -F % '{print $1;}') @@ -379,39 +362,8 @@ ndp_link_activation_body() pkt=$(make_pkt_str_na $linklocal b2:a1:00:00:00:02) atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'" -} -cleanup() -{ - env RUMP_SERVER=$SOCKSRC rump.halt - env RUMP_SERVER=$SOCKDST rump.halt -} - -dump_src() -{ - export RUMP_SERVER=$SOCKSRC - rump.netstat -nr - rump.ndp -n -a - rump.ifconfig - $HIJACKING dmesg -} - -dump_dst() -{ - export RUMP_SERVER=$SOCKDST - rump.netstat -nr - rump.ndp -n -a - rump.ifconfig - $HIJACKING dmesg -} - -dump() -{ - dump_src - dump_dst - shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - - $DEBUG && gdb -ex bt /usr/bin/rump_server rump_server.core - $DEBUG && gdb -ex bt /usr/sbin/rump.ndp rump.ndp.core + rump_server_destroy_ifaces } ndp_cache_expiration_cleanup() diff --git a/contrib/netbsd-tests/net/ndp/t_ra.sh b/contrib/netbsd-tests/net/ndp/t_ra.sh index cf81683..b234570 100755 --- a/contrib/netbsd-tests/net/ndp/t_ra.sh +++ b/contrib/netbsd-tests/net/ndp/t_ra.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_ra.sh,v 1.3 2016/08/10 23:07:57 kre Exp $ +# $NetBSD: t_ra.sh,v 1.20 2017/01/11 03:15:44 ozaki-r Exp $ # # Copyright (c) 2015 Internet Initiative Japan Inc. # All rights reserved. @@ -25,27 +25,49 @@ # POSSIBILITY OF SUCH DAMAGE. # -RUMPFLAGS="-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6" -RUMPFLAGS="${RUMPFLAGS} -lrumpnet_shmif -lrumpdev" -RUMPFLAGS="${RUMPFLAGS} -lrumpvfs -lrumpfs_ffs" - RUMPSRV=unix://r1 +RUMPSRV1_2=unix://r12 RUMPCLI=unix://r2 +RUMPSRV3=unix://r3 +RUMPSRV4=unix://r4 IP6SRV=fc00:1::1 +IP6SRV1_2=fc00:1::2 +IP6SRV_PREFIX=fc00:1: IP6CLI=fc00:2::2 -PIDFILE=/var/run/rump.rtadvd.pid +IP6SRV3=fc00:3::1 +IP6SRV3_PREFIX=fc00:3: +IP6SRV4=fc00:4::1 +IP6SRV4_PREFIX=fc00:4: +PIDFILE=./rump.rtadvd.pid +PIDFILE1_2=./rump.rtadvd.pid12 +PIDFILE3=./rump.rtadvd.pid3 +PIDFILE4=./rump.rtadvd.pid4 CONFIG=./rtadvd.conf -DEBUG=true +WAITTIME=2 +DEBUG=${DEBUG:-true} + +init_server() +{ + + export RUMP_SERVER=$1 + atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.forwarding=1 + export LD_PRELOAD=/usr/lib/librumphijack.so + atf_check -s exit:0 mkdir -p /rump/var/chroot/rtadvd + unset LD_PRELOAD + unset RUMP_SERVER +} setup_shmif0() { - local IP6ADDR=${1} - shift + local sock=$1 + local IP6ADDR=$2 + + rump_server_add_iface $sock shmif0 bus1 - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 + export RUMP_SERVER=$sock atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6ADDR} atf_check -s exit:0 rump.ifconfig shmif0 up + atf_check -s exit:0 rump.ifconfig -w 10 $DEBUG && rump.ifconfig } @@ -72,41 +94,81 @@ shmif0:\ _EOF } -atf_test_case basic cleanup -basic_head() +start_rtadvd() +{ + local sock=$1 + local pidfile=$2 + + export RUMP_SERVER=$sock + atf_check -s exit:0 rump.rtadvd -c ${CONFIG} -p $pidfile shmif0 + while [ ! -f $pidfile ]; do + sleep 0.2 + done + unset RUMP_SERVER +} + +check_entries() +{ + local cli=$1 + local srv=$2 + local addr_prefix=$3 + local mac_srv= ll_srv= + + ll_srv=$(get_linklocal_addr $srv shmif0) + mac_srv=$(get_macaddr $srv shmif0) + + export RUMP_SERVER=$cli + $DEBUG && dump_entries + atf_check -s exit:0 -o match:'if=shmif0' rump.ndp -r + atf_check -s exit:0 -o match:'advertised' rump.ndp -p + atf_check -s exit:0 -o match:"${ll_srv}%shmif0 \(reachable\)" rump.ndp -p + atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0 + atf_check -s exit:0 \ + -o match:"$ll_srv%shmif0 +$mac_srv +shmif0 +(23h59m|1d0h0m)..s S R" \ + rump.ndp -n -a + atf_check -s exit:0 -o match:$addr_prefix rump.ndp -n -a + atf_check -s exit:0 -o match:"$addr_prefix.+" \ + rump.ifconfig shmif0 inet6 + unset RUMP_SERVER +} + +dump_entries() +{ + + echo ndp -n -a + rump.ndp -n -a + echo ndp -p + rump.ndp -p + echo ndp -r + rump.ndp -r +} + +atf_test_case ra_basic cleanup +ra_basic_head() { atf_set "descr" "Tests for basic functions of router advaertisement(RA)" atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" } -basic_body() +ra_basic_body() { - atf_check -s exit:0 rump_server ${RUMPFLAGS} ${RUMPSRV} - atf_check -s exit:0 rump_server ${RUMPFLAGS} ${RUMPCLI} + rump_server_fs_start $RUMPSRV netinet6 + rump_server_start $RUMPCLI netinet6 - export RUMP_SERVER=${RUMPSRV} - setup_shmif0 ${IP6SRV} - atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.forwarding=1 - export LD_PRELOAD=/usr/lib/librumphijack.so - atf_check -s exit:0 mkdir -p /rump/var/chroot/rtadvd - unset LD_PRELOAD - unset RUMP_SERVER + setup_shmif0 ${RUMPSRV} ${IP6SRV} + init_server $RUMPSRV + setup_shmif0 ${RUMPCLI} ${IP6CLI} export RUMP_SERVER=${RUMPCLI} - setup_shmif0 ${IP6CLI} $DEBUG && rump.ndp -n -a atf_check -s exit:0 -o match:'= 0' rump.sysctl net.inet6.ip6.accept_rtadv unset RUMP_SERVER create_rtadvdconfig - - export RUMP_SERVER=${RUMPSRV} - atf_check -s exit:0 rump.rtadvd -c ${CONFIG} shmif0 - atf_check -s exit:0 sleep 3 - atf_check -s exit:0 -o ignore -e empty cat ${PIDFILE} - unset RUMP_SERVER + start_rtadvd $RUMPSRV $PIDFILE + sleep $WAITTIME export RUMP_SERVER=${RUMPCLI} atf_check -s exit:0 -o empty rump.ndp -r @@ -124,30 +186,482 @@ basic_body() atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1 unset RUMP_SERVER - export RUMP_SERVER=${RUMPSRV} - atf_check -s exit:0 rump.rtadvd -c ${CONFIG} shmif0 - atf_check -s exit:0 sleep 3 - atf_check -s exit:0 -o ignore -e empty cat ${PIDFILE} + start_rtadvd $RUMPSRV $PIDFILE + sleep $WAITTIME + + check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX + + atf_check -s exit:0 kill -TERM `cat ${PIDFILE}` + wait_term ${PIDFILE} + + rump_server_destroy_ifaces +} + +ra_basic_cleanup() +{ + + if [ -f ${PIDFILE} ]; then + kill -TERM `cat ${PIDFILE}` + wait_term ${PIDFILE} + fi + + $DEBUG && dump + cleanup +} + +atf_test_case ra_flush_prefix_entries cleanup +ra_flush_prefix_entries_head() +{ + + atf_set "descr" "Tests for flushing prefixes (ndp -P)" + atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" +} + +ra_flush_prefix_entries_body() +{ + + rump_server_fs_start $RUMPSRV netinet6 + rump_server_start $RUMPCLI netinet6 + + setup_shmif0 ${RUMPSRV} ${IP6SRV} + setup_shmif0 ${RUMPCLI} ${IP6CLI} + + init_server $RUMPSRV + + create_rtadvdconfig + + export RUMP_SERVER=${RUMPCLI} + atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1 unset RUMP_SERVER + start_rtadvd $RUMPSRV $PIDFILE + sleep $WAITTIME + + check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX + export RUMP_SERVER=${RUMPCLI} - $DEBUG && rump.ndp -n -a - $DEBUG && rump.ndp -r + + # Terminate rtadvd to prevent new RA messages from coming + # Note that ifconfig down; kill -TERM doesn't work + kill -KILL `cat ${PIDFILE}` + + # Flush all the entries in the prefix list + atf_check -s exit:0 rump.ndp -P + + $DEBUG && dump_entries atf_check -s exit:0 -o match:'if=shmif0' rump.ndp -r - atf_check -s exit:0 -o match:'advertised' rump.ndp -p + atf_check -s exit:0 -o empty rump.ndp -p atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0 - atf_check -s exit:0 -o match:'23h59m..s S R' rump.ndp -n -a + atf_check -s exit:0 -o match:'(23h59m|1d0h0m)..s S R' rump.ndp -n -a + atf_check -s exit:0 -o match:'fc00:1:' rump.ndp -n -a + atf_check -s exit:0 -o not-match:'fc00:1:' rump.ifconfig shmif0 inet6 + unset RUMP_SERVER + + rump_server_destroy_ifaces +} + +ra_flush_prefix_entries_cleanup() +{ + + $DEBUG && dump + cleanup +} + +atf_test_case ra_flush_defrouter_entries cleanup +ra_flush_defrouter_entries_head() +{ + + atf_set "descr" "Tests for flushing default routers (ndp -R)" + atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" +} + +ra_flush_defrouter_entries_body() +{ + + rump_server_fs_start $RUMPSRV netinet6 + rump_server_start $RUMPCLI netinet6 + + setup_shmif0 ${RUMPSRV} ${IP6SRV} + setup_shmif0 ${RUMPCLI} ${IP6CLI} + + init_server $RUMPSRV + + create_rtadvdconfig + + export RUMP_SERVER=${RUMPCLI} + atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1 + unset RUMP_SERVER + + start_rtadvd $RUMPSRV $PIDFILE + sleep $WAITTIME + + check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX + + export RUMP_SERVER=${RUMPCLI} + + # Terminate rtadvd to prevent new RA messages from coming + # Note that ifconfig down; kill -TERM doesn't work + kill -KILL `cat ${PIDFILE}` + + # Flush all the entries in the default router list + atf_check -s exit:0 rump.ndp -R + + $DEBUG && dump_entries + atf_check -s exit:0 -o empty rump.ndp -r + atf_check -s exit:0 -o match:'No advertising router' rump.ndp -p + atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0 + atf_check -s exit:0 -o match:'(23h59m|1d0h0m)..s S R' rump.ndp -n -a atf_check -s exit:0 -o match:'fc00:1:' rump.ndp -n -a atf_check -s exit:0 -o match:'fc00:1:' rump.ifconfig shmif0 inet6 unset RUMP_SERVER + rump_server_destroy_ifaces +} + +ra_flush_defrouter_entries_cleanup() +{ + + $DEBUG && dump + cleanup +} + +atf_test_case ra_delete_address cleanup +ra_delete_address_head() +{ + + atf_set "descr" "Tests for deleting auto-configured address" + atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" +} + +ra_delete_address_body() +{ + + rump_server_fs_start $RUMPSRV netinet6 + rump_server_start $RUMPCLI netinet6 + + setup_shmif0 ${RUMPSRV} ${IP6SRV} + setup_shmif0 ${RUMPCLI} ${IP6CLI} + + init_server $RUMPSRV + + create_rtadvdconfig + + export RUMP_SERVER=${RUMPCLI} + atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1 + unset RUMP_SERVER + + start_rtadvd $RUMPSRV $PIDFILE + sleep $WAITTIME + + check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX + + export RUMP_SERVER=${RUMPCLI} + $DEBUG && rump.ifconfig shmif0 + atf_check -s exit:0 rump.ifconfig shmif0 inet6 \ + $(rump.ifconfig shmif0 |awk '/AUTOCONF/ {print $2}') delete + unset RUMP_SERVER + atf_check -s exit:0 kill -TERM `cat ${PIDFILE}` wait_term ${PIDFILE} - return 0 + rump_server_destroy_ifaces +} + +ra_delete_address_cleanup() +{ + + if [ -f ${PIDFILE} ]; then + kill -TERM `cat ${PIDFILE}` + wait_term ${PIDFILE} + fi + + $DEBUG && dump + cleanup +} + +atf_test_case ra_multiple_routers cleanup +ra_multiple_routers_head() +{ + + atf_set "descr" "Tests for multiple routers" + atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" +} + +ra_multiple_routers_body() +{ + local n= + + rump_server_fs_start $RUMPSRV netinet6 + rump_server_fs_start $RUMPSRV3 netinet6 + rump_server_start $RUMPCLI netinet6 + + setup_shmif0 ${RUMPSRV} ${IP6SRV} + setup_shmif0 ${RUMPSRV3} ${IP6SRV3} + setup_shmif0 ${RUMPCLI} ${IP6CLI} + + init_server $RUMPSRV + init_server $RUMPSRV3 + + create_rtadvdconfig + + export RUMP_SERVER=${RUMPCLI} + atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1 + unset RUMP_SERVER + + start_rtadvd $RUMPSRV $PIDFILE + start_rtadvd $RUMPSRV3 $PIDFILE3 + sleep $WAITTIME + + check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX + check_entries $RUMPCLI $RUMPSRV3 $IP6SRV3_PREFIX + + export RUMP_SERVER=$RUMPCLI + # Two prefixes are advertised by differnt two routers + n=$(rump.ndp -p |grep 'advertised by' |wc -l) + atf_check_equal $n 2 + unset RUMP_SERVER + + atf_check -s exit:0 kill -TERM `cat ${PIDFILE}` + wait_term ${PIDFILE} + atf_check -s exit:0 kill -TERM `cat ${PIDFILE3}` + wait_term ${PIDFILE3} + + rump_server_destroy_ifaces +} + +ra_multiple_routers_cleanup() +{ + + if [ -f ${PIDFILE} ]; then + kill -TERM `cat ${PIDFILE}` + wait_term ${PIDFILE} + fi + if [ -f ${PIDFILE3} ]; then + kill -TERM `cat ${PIDFILE3}` + wait_term ${PIDFILE3} + fi + + $DEBUG && dump + cleanup +} + +atf_test_case ra_multiple_routers_single_prefix cleanup +ra_multiple_routers_single_prefix_head() +{ + + atf_set "descr" "Tests for multiple routers with a single prefix" + atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" +} + +ra_multiple_routers_single_prefix_body() +{ + local n= + + rump_server_fs_start $RUMPSRV netinet6 + rump_server_fs_start $RUMPSRV1_2 netinet6 + rump_server_start $RUMPCLI netinet6 + + setup_shmif0 ${RUMPSRV} ${IP6SRV} + setup_shmif0 ${RUMPSRV1_2} ${IP6SRV1_2} + setup_shmif0 ${RUMPCLI} ${IP6CLI} + + init_server $RUMPSRV + init_server $RUMPSRV1_2 + + create_rtadvdconfig + + export RUMP_SERVER=${RUMPCLI} + atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1 + unset RUMP_SERVER + + start_rtadvd $RUMPSRV $PIDFILE + start_rtadvd $RUMPSRV1_2 $PIDFILE1_2 + sleep $WAITTIME + + check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX + check_entries $RUMPCLI $RUMPSRV1_2 $IP6SRV_PREFIX + + export RUMP_SERVER=$RUMPCLI + # One prefix is advertised by differnt two routers + n=$(rump.ndp -p |grep 'advertised by' |wc -l) + atf_check_equal $n 1 + unset RUMP_SERVER + + atf_check -s exit:0 kill -TERM `cat ${PIDFILE}` + wait_term ${PIDFILE} + atf_check -s exit:0 kill -TERM `cat ${PIDFILE1_2}` + wait_term ${PIDFILE1_2} + + rump_server_destroy_ifaces +} + +ra_multiple_routers_single_prefix_cleanup() +{ + + if [ -f ${PIDFILE} ]; then + kill -TERM `cat ${PIDFILE}` + wait_term ${PIDFILE} + fi + if [ -f ${PIDFILE1_2} ]; then + kill -TERM `cat ${PIDFILE1_2}` + wait_term ${PIDFILE1_2} + fi + + $DEBUG && dump + cleanup +} + +atf_test_case ra_multiple_routers_maxifprefixes cleanup +ra_multiple_routers_maxifprefixes_head() +{ + + atf_set "descr" "Tests for exceeding the number of maximum prefixes" + atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" +} + +ra_multiple_routers_maxifprefixes_body() +{ + local n= + + rump_server_fs_start $RUMPSRV netinet6 + rump_server_fs_start $RUMPSRV3 netinet6 + rump_server_fs_start $RUMPSRV4 netinet6 + rump_server_start $RUMPCLI netinet6 + + setup_shmif0 ${RUMPSRV} ${IP6SRV} + setup_shmif0 ${RUMPSRV3} ${IP6SRV3} + setup_shmif0 ${RUMPSRV4} ${IP6SRV4} + setup_shmif0 ${RUMPCLI} ${IP6CLI} + + init_server $RUMPSRV + init_server $RUMPSRV3 + init_server $RUMPSRV4 + + create_rtadvdconfig + + export RUMP_SERVER=${RUMPCLI} + atf_check -s exit:0 -o match:'0.->.1' \ + rump.sysctl -w net.inet6.ip6.accept_rtadv=1 + # Limit the maximum number of prefix entries to 2 + atf_check -s exit:0 -o match:'16.->.2' \ + rump.sysctl -w net.inet6.ip6.maxifprefixes=2 + unset RUMP_SERVER + + start_rtadvd $RUMPSRV $PIDFILE + start_rtadvd $RUMPSRV3 $PIDFILE3 + sleep $WAITTIME + + check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX + check_entries $RUMPCLI $RUMPSRV3 $IP6SRV3_PREFIX + + start_rtadvd $RUMPSRV4 $PIDFILE4 + sleep $WAITTIME + + export RUMP_SERVER=${RUMPCLI} + $DEBUG && dump_entries + # There should remain two prefixes + n=$(rump.ndp -p |grep 'advertised by' |wc -l) + atf_check_equal $n 2 + # TODO check other conditions + unset RUMP_SERVER + + atf_check -s exit:0 kill -TERM `cat ${PIDFILE}` + wait_term ${PIDFILE} + atf_check -s exit:0 kill -TERM `cat ${PIDFILE3}` + wait_term ${PIDFILE3} + atf_check -s exit:0 kill -TERM `cat ${PIDFILE4}` + wait_term ${PIDFILE4} + + rump_server_destroy_ifaces +} + +ra_multiple_routers_maxifprefixes_cleanup() +{ + + if [ -f ${PIDFILE} ]; then + kill -TERM `cat ${PIDFILE}` + wait_term ${PIDFILE} + fi + if [ -f ${PIDFILE3} ]; then + kill -TERM `cat ${PIDFILE3}` + wait_term ${PIDFILE3} + fi + if [ -f ${PIDFILE4} ]; then + kill -TERM `cat ${PIDFILE4}` + wait_term ${PIDFILE4} + fi + + $DEBUG && dump + cleanup +} + +atf_test_case ra_temporary_address cleanup +ra_temporary_address_head() +{ + + atf_set "descr" "Tests for IPv6 temporary address" + atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig" +} + +ra_temporary_address_body() +{ + + rump_server_fs_start $RUMPSRV netinet6 + rump_server_start $RUMPCLI netinet6 + + setup_shmif0 ${RUMPSRV} ${IP6SRV} + init_server $RUMPSRV + + setup_shmif0 ${RUMPCLI} ${IP6CLI} + export RUMP_SERVER=${RUMPCLI} + $DEBUG && rump.ndp -n -a + atf_check -s exit:0 -o match:'= 0' \ + rump.sysctl net.inet6.ip6.accept_rtadv + atf_check -s exit:0 -o match:'= 0' \ + rump.sysctl net.inet6.ip6.use_tempaddr + unset RUMP_SERVER + + create_rtadvdconfig + start_rtadvd $RUMPSRV $PIDFILE + sleep $WAITTIME + + export RUMP_SERVER=${RUMPCLI} + atf_check -s exit:0 -o empty rump.ndp -r + atf_check -s exit:0 -o not-match:'advertised' rump.ndp -p + atf_check -s exit:0 -o match:'linkmtu=0' rump.ndp -n -i shmif0 + atf_check -s exit:0 -o not-match:'S R' rump.ndp -n -a + atf_check -s exit:0 -o not-match:'fc00:1:' rump.ndp -n -a + atf_check -s exit:0 -o not-match:'fc00:1:' rump.ifconfig shmif0 inet6 + unset RUMP_SERVER + + atf_check -s exit:0 kill -TERM `cat ${PIDFILE}` + wait_term ${PIDFILE} + + export RUMP_SERVER=${RUMPCLI} + atf_check -s exit:0 -o match:'0.->.1' \ + rump.sysctl -w net.inet6.ip6.accept_rtadv=1 + atf_check -s exit:0 -o match:'0.->.1' \ + rump.sysctl -w net.inet6.ip6.use_tempaddr=1 + unset RUMP_SERVER + + start_rtadvd $RUMPSRV $PIDFILE + sleep $WAITTIME + + check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX + + # Check temporary address + export RUMP_SERVER=${RUMPCLI} + atf_check -s exit:0 -o match:"$IP6SRV_PREFIX.+" \ + rump.ifconfig shmif0 inet6 + unset RUMP_SERVER + + atf_check -s exit:0 kill -TERM `cat ${PIDFILE}` + wait_term ${PIDFILE} + + rump_server_destroy_ifaces } -basic_cleanup() +ra_temporary_address_cleanup() { if [ -f ${PIDFILE} ]; then @@ -155,12 +669,19 @@ basic_cleanup() wait_term ${PIDFILE} fi - env RUMP_SERVER=${RUMPSRV} rump.halt - env RUMP_SERVER=${RUMPCLI} rump.halt + $DEBUG && dump + cleanup } atf_init_test_cases() { - atf_add_test_case basic + atf_add_test_case ra_basic + atf_add_test_case ra_flush_prefix_entries + atf_add_test_case ra_flush_defrouter_entries + atf_add_test_case ra_delete_address + atf_add_test_case ra_multiple_routers + atf_add_test_case ra_multiple_routers_single_prefix + atf_add_test_case ra_multiple_routers_maxifprefixes + atf_add_test_case ra_temporary_address } diff --git a/contrib/netbsd-tests/net/net/t_forwarding.sh b/contrib/netbsd-tests/net/net/t_forwarding.sh index 9e96738..fc30530 100755 --- a/contrib/netbsd-tests/net/net/t_forwarding.sh +++ b/contrib/netbsd-tests/net/net/t_forwarding.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_forwarding.sh,v 1.15 2016/08/10 21:33:52 kre Exp $ +# $NetBSD: t_forwarding.sh,v 1.19 2016/11/25 08:51:17 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,9 +25,6 @@ # POSSIBILITY OF SUCH DAMAGE. # -inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif -lrumpdev" -inet6server="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_shmif -lrumpdev" - SOCKSRC=unix://commsock1 SOCKFWD=unix://commsock2 SOCKDST=unix://commsock3 @@ -40,10 +37,9 @@ IP6SRC=fc00:0:0:1::2 IP6SRCGW=fc00:0:0:1::1 IP6DSTGW=fc00:0:0:2::1 IP6DST=fc00:0:0:2::2 -HTTPD_PID=httpd.pid HTML_FILE=index.html -DEBUG=false +DEBUG=${DEBUG:-false} TIMEOUT=5 atf_test_case ipforwarding_v4 cleanup @@ -64,6 +60,18 @@ ipforwarding_v6_head() atf_set "require.progs" "rump_server" } +ipforwarding_fastforward_v4_head() +{ + atf_set "descr" "Tests for IPv4 fastforward" + atf_set "require.progs" "rump_server" +} + +ipforwarding_fastforward_v6_head() +{ + atf_set "descr" "Tests for IPv6 fastfoward" + atf_set "require.progs" "rump_server" +} + ipforwarding_misc_head() { atf_set "descr" "Does IPv4 forwarding tests" @@ -78,9 +86,9 @@ setup_endpoint() mode=${4} gw=${5} + rump_server_add_iface $sock shmif0 $bus + export RUMP_SERVER=${sock} - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${bus} if [ $mode = "ipv6" ]; then atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${addr} atf_check -s exit:0 -o ignore rump.route add -inet6 default ${gw} @@ -116,12 +124,10 @@ setup_forwarder() { mode=${1} - export RUMP_SERVER=$SOCKFWD - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 + rump_server_add_iface $SOCKFWD shmif0 bus1 + rump_server_add_iface $SOCKFWD shmif1 bus2 - atf_check -s exit:0 rump.ifconfig shmif1 create - atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus2 + export RUMP_SERVER=$SOCKFWD if [ $mode = "ipv6" ]; then atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6SRCGW} @@ -146,9 +152,9 @@ setup_forwarder() setup() { - atf_check -s exit:0 ${inetserver} $SOCKSRC - atf_check -s exit:0 ${inetserver} $SOCKFWD - atf_check -s exit:0 ${inetserver} $SOCKDST + rump_server_start $SOCKSRC + rump_server_start $SOCKFWD + rump_server_start $SOCKDST setup_endpoint $SOCKSRC $IP4SRC bus1 ipv4 $IP4SRCGW setup_endpoint $SOCKDST $IP4DST bus2 ipv4 $IP4DSTGW @@ -157,29 +163,15 @@ setup() setup6() { - atf_check -s exit:0 ${inet6server} $SOCKSRC - atf_check -s exit:0 ${inet6server} $SOCKFWD - atf_check -s exit:0 ${inet6server} $SOCKDST + rump_server_start $SOCKSRC netinet6 + rump_server_start $SOCKFWD netinet6 + rump_server_start $SOCKDST netinet6 setup_endpoint $SOCKSRC $IP6SRC bus1 ipv6 $IP6SRCGW setup_endpoint $SOCKDST $IP6DST bus2 ipv6 $IP6DSTGW setup_forwarder ipv6 } -setup_bozo() -{ - local ip=$1 - - export RUMP_SERVER=$SOCKDST - - touch $HTML_FILE - # start bozo in daemon mode - atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \ - /usr/libexec/httpd -P $HTTPD_PID -i $ip -b -s $(pwd) - - $DEBUG && rump.netstat -a -} - test_http_get() { local ip=$1 @@ -270,15 +262,8 @@ teardown_icmp_bmcastecho() teardown_interfaces() { - export RUMP_SERVER=$SOCKSRC - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 destroy - export RUMP_SERVER=$SOCKFWD - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 destroy - atf_check -s exit:0 -o ignore rump.ifconfig shmif1 destroy - - export RUMP_SERVER=$SOCKDST - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 destroy + rump_server_destroy_ifaces } test_setup_forwarding() @@ -307,33 +292,6 @@ test_teardown_forwarding6() rump.sysctl net.inet6.ip6.forwarding } -cleanup() -{ - env RUMP_SERVER=$SOCKSRC rump.halt - env RUMP_SERVER=$SOCKFWD rump.halt - env RUMP_SERVER=$SOCKDST rump.halt -} - -cleanup_bozo() -{ - - if [ -f $HTTPD_PID ]; then - kill -9 "$(cat $HTTPD_PID)" - rm -f $HTTPD_PID - fi - rm -f $HTML_FILE -} - -dump() -{ - env RUMP_SERVER=$SOCKSRC rump.netstat -nr - env RUMP_SERVER=$SOCKFWD rump.netstat -nr - env RUMP_SERVER=$SOCKDST rump.netstat -nr - - /usr/bin/shmif_dumpbus -p - bus1 2>/dev/null| /usr/sbin/tcpdump -n -e -r - - /usr/bin/shmif_dumpbus -p - bus2 2>/dev/null| /usr/sbin/tcpdump -n -e -r - -} - test_ping_failure() { export RUMP_SERVER=$SOCKSRC @@ -481,7 +439,10 @@ ipforwarding_fastforward_v4_body() setup_forwarding test_setup_forwarding - setup_bozo $IP4DST + touch $HTML_FILE + start_httpd $SOCKDST $IP4DST + $DEBUG && rump.netstat -a + test_http_get $IP4DST teardown_interfaces @@ -495,7 +456,10 @@ ipforwarding_fastforward_v6_body() setup_forwarding6 test_setup_forwarding6 - setup_bozo $IP6DST + touch $HTML_FILE + start_httpd $SOCKDST $IP6DST + $DEBUG && rump.netstat -a + test_http_get "[$IP6DST]" teardown_interfaces @@ -513,7 +477,10 @@ ipforwarding_misc_body() test_directed_broadcast - setup_bozo $IP4DST + touch $HTML_FILE + start_httpd $SOCKDST $IP4DST + $DEBUG && rump.netstat -a + test_sysctl_ttl $IP4DST teardown_interfaces @@ -522,34 +489,34 @@ ipforwarding_misc_body() ipforwarding_v4_cleanup() { - dump + $DEBUG && dump cleanup } ipforwarding_v6_cleanup() { - dump + $DEBUG && dump cleanup } ipforwarding_fastforward_v4_cleanup() { - dump - cleanup_bozo + $DEBUG && dump + stop_httpd cleanup } ipforwarding_fastforward_v6_cleanup() { - dump - cleanup_bozo + $DEBUG && dump + stop_httpd cleanup } ipforwarding_misc_cleanup() { - dump - cleanup_bozo + $DEBUG && dump + stop_httpd cleanup } diff --git a/contrib/netbsd-tests/net/net/t_ipaddress.sh b/contrib/netbsd-tests/net/net/t_ipaddress.sh index a46f484..4cdd954 100755 --- a/contrib/netbsd-tests/net/net/t_ipaddress.sh +++ b/contrib/netbsd-tests/net/net/t_ipaddress.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_ipaddress.sh,v 1.3 2016/08/10 21:33:52 kre Exp $ +# $NetBSD: t_ipaddress.sh,v 1.9 2016/12/15 02:43:56 ozaki-r Exp $ # # Copyright (c) 2015 Internet Initiative Japan Inc. # All rights reserved. @@ -25,61 +25,37 @@ # POSSIBILITY OF SUCH DAMAGE. # -SERVER="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif -lrumpdev" -SERVER6="$SERVER -lrumpnet_netinet6" SOCK_LOCAL=unix://commsock1 BUS=bus -DEBUG=false - -check_entry() -{ - local ip=$(echo $1 |sed 's/\./\\./g') - local word=$2 - - atf_check -s exit:0 -o match:"$word" -e ignore -x \ - "rump.netstat -rn | grep ^'$ip'" -} - -check_entry_fail() -{ - local ip=$(echo $1 |sed 's/\./\\./g') - local flags=$2 # Not used currently - - atf_check -s not-exit:0 -e ignore -x \ - "rump.netstat -rn | grep ^'$ip'" -} +DEBUG=${DEBUG:-false} test_same_address() { local ip=10.0.0.1 local net=10.0.0/24 - atf_check -s exit:0 ${SERVER} ${SOCK_LOCAL} + rump_server_start $SOCK_LOCAL + rump_server_add_iface $SOCK_LOCAL shmif0 $BUS + export RUMP_SERVER=$SOCK_LOCAL - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS} atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip/24 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up atf_check -s exit:0 -o ignore rump.ifconfig -w 10 $DEBUG && rump.netstat -nr -f inet - check_entry $ip UHl - check_entry $ip lo0 - check_entry $ip 'link#2' - check_entry $net U - check_entry $net shmif0 - check_entry $net 'link#2' + check_route $ip 'link#2' UHl lo0 + check_route $net 'link#2' UC shmif0 # Delete the address atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip delete $DEBUG && rump.netstat -nr -f inet - check_entry_fail $ip - check_entry_fail $net + check_route_no_entry $ip + check_route_no_entry $net # Assign the same address again atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip/24 @@ -87,20 +63,18 @@ test_same_address() $DEBUG && rump.netstat -nr -f inet - check_entry $ip UHl - check_entry $ip lo0 - check_entry $ip 'link#2' - check_entry $net U - check_entry $net shmif0 - check_entry $net 'link#2' + check_route $ip 'link#2' UHl lo0 + check_route $net 'link#2' UC shmif0 # Delete the address again atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip delete $DEBUG && rump.netstat -nr -f inet - check_entry_fail $ip - check_entry_fail $net + check_route_no_entry $ip + check_route_no_entry $net + + rump_server_destroy_ifaces } test_same_address6() @@ -108,31 +82,27 @@ test_same_address6() local ip=fc00::1 local net=fc00::/64 - atf_check -s exit:0 ${SERVER6} ${SOCK_LOCAL} + rump_server_start $SOCK_LOCAL netinet6 + rump_server_add_iface $SOCK_LOCAL shmif0 $BUS + export RUMP_SERVER=$SOCK_LOCAL - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS} atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up atf_check -s exit:0 -o ignore rump.ifconfig -w 10 $DEBUG && rump.netstat -nr -f inet6 - check_entry $ip UHl - check_entry $ip lo0 - check_entry $ip 'link#2' - check_entry $net U - check_entry $net shmif0 - check_entry $net 'link#2' + check_route $ip 'link#2' UHl lo0 + check_route $net 'link#2' UC shmif0 # Delete the address atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip delete $DEBUG && rump.netstat -nr -f inet6 - check_entry_fail $ip - check_entry_fail $net + check_route_no_entry $ip + check_route_no_entry $net # Assign the same address again atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip @@ -140,27 +110,58 @@ test_same_address6() $DEBUG && rump.netstat -nr -f inet6 - check_entry $ip UHl - check_entry $ip lo0 - check_entry $ip 'link#2' - check_entry $net U - check_entry $net shmif0 - check_entry $net 'link#2' + check_route $ip 'link#2' UHl lo0 + check_route $net 'link#2' UC shmif0 # Delete the address again atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip delete $DEBUG && rump.netstat -nr -f inet6 - check_entry_fail $ip - check_entry_fail $net + check_route_no_entry $ip + check_route_no_entry $net + + rump_server_destroy_ifaces } -cleanup() +test_auto_linklocal() { - $DEBUG && shmif_dumpbus -p - $BUS 2>/dev/null | tcpdump -n -e -r - - env RUMP_SERVER=$SOCK_LOCAL rump.halt + rump_server_start $SOCK_LOCAL netinet6 + rump_server_add_iface $SOCK_LOCAL shmif0 $BUS + + export RUMP_SERVER=$SOCK_LOCAL + + # + # Test enabled auto linklocal + # + + # Check default value + atf_check -s exit:0 -o match:"1" rump.sysctl -n net.inet6.ip6.auto_linklocal + + atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up + atf_check -s exit:0 -o ignore rump.ifconfig -w 10 + + $DEBUG && rump.netstat -nr -f inet + + # IPv6 link-local address is set + atf_check -s exit:0 -o match:"inet6 fe80::" rump.ifconfig shmif0 + + # + # Test disabled auto linklocal + # + atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet6.ip6.auto_linklocal=0 + + rump_server_add_iface $SOCK_LOCAL shmif1 $BUS + atf_check -s exit:0 -o ignore rump.ifconfig shmif1 up + atf_check -s exit:0 -o ignore rump.ifconfig -w 10 + + $DEBUG && rump.netstat -nr -f inet + + # IPv6 link-local address is not set + atf_check -s exit:0 -o not-match:"inet6 fe80::" rump.ifconfig shmif1 + + rump_server_destroy_ifaces } add_test() @@ -177,6 +178,7 @@ add_test() test_${name}; \ }; \ ipaddr_${name}_cleanup() { \ + $DEBUG && dump; \ cleanup; \ }" atf_add_test_case "ipaddr_${name}" @@ -187,4 +189,5 @@ atf_init_test_cases() add_test same_address "Assigning/deleting an IP address twice" add_test same_address6 "Assigning/deleting an IPv6 address twice" + add_test auto_linklocal "Assigning an IPv6 link-local address automatically" } diff --git a/contrib/netbsd-tests/net/net/t_ipv6_lifetime.sh b/contrib/netbsd-tests/net/net/t_ipv6_lifetime.sh index 5fb34d0..10e50fd 100755 --- a/contrib/netbsd-tests/net/net/t_ipv6_lifetime.sh +++ b/contrib/netbsd-tests/net/net/t_ipv6_lifetime.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_ipv6_lifetime.sh,v 1.2 2016/08/10 21:33:52 kre Exp $ +# $NetBSD: t_ipv6_lifetime.sh,v 1.6 2016/11/25 08:51:17 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,13 +25,12 @@ # POSSIBILITY OF SUCH DAMAGE. # -INET6SERVER="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpdev" -INET6SERVER="$INET6SERVER -lrumpnet_netinet6 -lrumpnet_shmif" - SOCK=unix://sock BUS=./bus -DEBUG=false +DEBUG=${DEBUG:-false} + +deprecated="[Dd][Ee][Pp][Rr][Ee][Cc][Aa][Tt][Ee][Dd]" atf_test_case basic cleanup @@ -47,11 +46,11 @@ basic_body() local bonus=2 local ip="fc00::1" - atf_check -s exit:0 ${INET6SERVER} $SOCK + rump_server_start $SOCK netinet6 + rump_server_add_iface $SOCK shmif0 $BUS + export RUMP_SERVER=$SOCK - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS atf_check -s exit:0 rump.ifconfig shmif0 up # A normal IP address doesn't contain preferred/valid lifetime @@ -69,7 +68,7 @@ basic_body() atf_check -s exit:0 sleep $(($time + $bonus)) $DEBUG && rump.ifconfig -L shmif0 # Should remain but marked as deprecated - atf_check -s exit:0 -o match:'deprecated' rump.ifconfig -L shmif0 + atf_check -s exit:0 -o match:"$ip.+$deprecated" rump.ifconfig -L shmif0 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip delete # Setting only a valid lifetime (invalid) @@ -87,38 +86,33 @@ basic_body() # Shouldn't remain anymore atf_check -s exit:0 -o not-match:"$ip" rump.ifconfig -L shmif0 + # Setting both preferred and valid lifetimes (pltime > vltime) + atf_check -s not-exit:0 -e match:'Invalid argument' rump.ifconfig \ + shmif0 inet6 $ip pltime $(($time * 2)) vltime $time + # Setting both preferred and valid lifetimes (pltime < vltime) atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip \ pltime $time vltime $((time * 2)) $DEBUG && rump.ifconfig -L shmif0 atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0 atf_check -s exit:0 -o match:'vltime' rump.ifconfig -L shmif0 + + if sysctl machdep.cpu_brand 2>/dev/null | grep QEMU >/dev/null 2>&1 + then + atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip delete + atf_skip "unreliable under qemu, skip until PR kern/43997 fixed" + fi + atf_check -s exit:0 sleep $(($time + $bonus)) $DEBUG && rump.ifconfig -L shmif0 # Should remain but marked as deprecated - atf_check -s exit:0 -o match:'deprecated' rump.ifconfig -L shmif0 + atf_check -s exit:0 -o match:"$ip.+$deprecated" rump.ifconfig -L shmif0 atf_check -s exit:0 sleep $(($time + $bonus)) $DEBUG && rump.ifconfig -L shmif0 # Shouldn't remain anymore atf_check -s exit:0 -o not-match:"$ip" rump.ifconfig -L shmif0 - # Setting both preferred and valid lifetimes (pltime > vltime) - atf_check -s not-exit:0 -e match:'Invalid argument' rump.ifconfig \ - shmif0 inet6 $ip pltime $(($time * 2)) vltime $time - - return 0 -} - -cleanup() -{ - env RUMP_SERVER=$SOCK rump.halt -} - -dump() -{ - env RUMP_SERVER=$SOCK rump.ifconfig - env RUMP_SERVER=$SOCK rump.netstat -nr - shmif_dumpbus -p - $BUS 2>/dev/null| tcpdump -n -e -r - + rump_server_destroy_ifaces } basic_cleanup() diff --git a/contrib/netbsd-tests/net/net/t_ipv6address.sh b/contrib/netbsd-tests/net/net/t_ipv6address.sh index 3448e86..539a16d 100755 --- a/contrib/netbsd-tests/net/net/t_ipv6address.sh +++ b/contrib/netbsd-tests/net/net/t_ipv6address.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_ipv6address.sh,v 1.7 2016/08/10 21:33:52 kre Exp $ +# $NetBSD: t_ipv6address.sh,v 1.12 2016/12/14 02:50:42 ozaki-r Exp $ # # Copyright (c) 2015 Internet Initiative Japan Inc. # All rights reserved. @@ -24,8 +24,9 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -SERVER="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif -lrumpdev" -SERVER6="$SERVER -lrumpnet_netinet6" +SERVER="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet" +SERVER="${SERVER} -lrumpnet_shmif -lrumpdev" +SERVER6="${SERVER} -lrumpnet_netinet6" SOCKSRC=unix://commsock1 SOCKFWD=unix://commsock2 @@ -40,7 +41,7 @@ BUS2=bus2 BUSSRC=bus_src BUSDST=bus_dst -DEBUG=true +DEBUG=${DEBUG:-true} TIMEOUT=3 atf_test_case linklocal cleanup @@ -118,41 +119,41 @@ setup_route() { local tmp_rump_server=$RUMP_SERVER - local src_if0_lladdr=`get_lladdr ${SOCKSRC} shmif0` - local dst_if0_lladdr=`get_lladdr ${SOCKDST} shmif0` - local fwd_if0_lladdr=`get_lladdr ${SOCKFWD} shmif0` - local fwd_if1_lladdr=`get_lladdr ${SOCKFWD} shmif1` + local src_if0_lladdr=`get_linklocal_addr ${SOCKSRC} shmif0` + local dst_if0_lladdr=`get_linklocal_addr ${SOCKDST} shmif0` + local fwd_if0_lladdr=`get_linklocal_addr ${SOCKFWD} shmif0` + local fwd_if1_lladdr=`get_linklocal_addr ${SOCKFWD} shmif1` export RUMP_SERVER=${SOCKSRC} - atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 default \ - ${fwd_if0_lladdr}%shmif0 - atf_check -s exit:0 -o match:"add net default:" rump.route add -inet6 default \ - ${fwd_if0_lladdr}%shmif0 + atf_check -s ignore -o ignore -e ignore \ + rump.route delete -inet6 default ${fwd_if0_lladdr}%shmif0 + atf_check -s exit:0 -o match:"add net default:" \ + rump.route add -inet6 default ${fwd_if0_lladdr}%shmif0 atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6SRC} atf_check -s exit:0 -o ignore rump.ifconfig -w 10 $DEBUG && rump.netstat -rn -f inet6 unset RUMP_SERVER export RUMP_SERVER=${SOCKDST} - atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 default \ - ${fwd_if1_lladdr}%shmif0 - atf_check -s exit:0 -o match:"add net default:" rump.route add -inet6 default \ - ${fwd_if1_lladdr}%shmif0 + atf_check -s ignore -o ignore -e ignore \ + rump.route delete -inet6 default ${fwd_if1_lladdr}%shmif0 + atf_check -s exit:0 -o match:"add net default:" \ + rump.route add -inet6 default ${fwd_if1_lladdr}%shmif0 atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6DST} atf_check -s exit:0 -o ignore rump.ifconfig -w 10 $DEBUG && rump.netstat -rn -f inet6 unset RUMP_SERVER export RUMP_SERVER=${SOCKFWD} - atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 ${IP6SRCNW} \ - ${src_if0_lladdr}%shmif0 - atf_check -s exit:0 -o match:"add net" rump.route add -inet6 ${IP6SRCNW} \ - ${src_if0_lladdr}%shmif0 - - atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 ${IP6DSTNW} \ - ${dst_if0_lladdr}%shmif1 - atf_check -s exit:0 -o match:"add net" rump.route add -inet6 ${IP6DSTNW} \ - ${dst_if0_lladdr}%shmif1 + atf_check -s ignore -o ignore -e ignore \ + rump.route delete -inet6 ${IP6SRCNW} ${src_if0_lladdr}%shmif0 + atf_check -s exit:0 -o match:"add net" \ + rump.route add -inet6 ${IP6SRCNW} ${src_if0_lladdr}%shmif0 + + atf_check -s ignore -o ignore -e ignore \ + rump.route delete -inet6 ${IP6DSTNW} ${dst_if0_lladdr}%shmif1 + atf_check -s exit:0 -o match:"add net" \ + rump.route add -inet6 ${IP6DSTNW} ${dst_if0_lladdr}%shmif1 atf_check -s exit:0 -o ignore rump.ifconfig -w 10 $DEBUG && rump.netstat -rn -f inet6 unset RUMP_SERVER @@ -197,17 +198,6 @@ cleanup_bus() export RUMP_SERVER=$tmp_rump_server } - -get_lladdr() -{ - export RUMP_SERVER=${1} - rump.ifconfig ${2} inet6 | grep "fe80" \ - | awk '{print $2}' | sed -e "s/%$2//g" - unset RUMP_SERVER - - return 0 -} - cleanup_rump_servers() { @@ -221,11 +211,11 @@ dump_bus() shmif_dumpbus -p - ${BUSSRC} 2>/dev/null| tcpdump -n -e -r - shmif_dumpbus -p - ${BUSDST} 2>/dev/null| tcpdump -n -e -r - - shmif_dumpbus -p - ${BUS1} 2>/dev/null| tcpdump -n -e -r - - shmif_dumpbus -p - ${BUS2} 2>/dev/null| tcpdump -n -e -r - + shmif_dumpbus -p - ${BUS1} 2>/dev/null| tcpdump -n -e -r - + shmif_dumpbus -p - ${BUS2} 2>/dev/null| tcpdump -n -e -r - } -dump() +_dump() { export RUMP_SERVER=${SOCKSRC} @@ -242,19 +232,21 @@ dump() linklocal_head() { - atf_set "descr" "Test for bassically function of the IPv6 linklocal address" - atf_set "require.progs" "rump_server rump.route rump.ifconfig rump.ping6" + atf_set "descr" \ + "Test for bassically function of the IPv6 linklocal address" + atf_set "require.progs" \ + "rump_server rump.route rump.ifconfig rump.ping6" } linklocal_body() { setup - local src_if0_lladdr=`get_lladdr ${SOCKSRC} shmif0` - local src_if1_lladdr=`get_lladdr ${SOCKSRC} shmif1` - local dst_if0_lladdr=`get_lladdr ${SOCKDST} shmif0` - local fwd_if0_lladdr=`get_lladdr ${SOCKFWD} shmif0` - local fwd_if1_lladdr=`get_lladdr ${SOCKFWD} shmif1` + local src_if0_lladdr=`get_linklocal_addr ${SOCKSRC} shmif0` + local src_if1_lladdr=`get_linklocal_addr ${SOCKSRC} shmif1` + local dst_if0_lladdr=`get_linklocal_addr ${SOCKDST} shmif0` + local fwd_if0_lladdr=`get_linklocal_addr ${SOCKFWD} shmif0` + local fwd_if1_lladdr=`get_linklocal_addr ${SOCKFWD} shmif1` export RUMP_SERVER=${SOCKSRC} $DEBUG && rump.ifconfig @@ -271,7 +263,7 @@ linklocal_body() atf_check -s ignore -o empty -e ignore \ -x "shmif_dumpbus -p - ${BUSSRC} | tcpdump -r - -n -p icmp6" atf_check -s ignore -o not-empty -e ignore \ - -x "shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6" + -x "shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6" cleanup_bus @@ -279,7 +271,7 @@ linklocal_body() rump.ping6 -c 1 -X $TIMEOUT -n -S ${src_if1_lladdr}%shmif1 \ ${fwd_if0_lladdr}%shmif0 atf_check -s ignore -o not-match:"${src_if1_lladdr}" -e ignore \ - -x "shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6" + -x "shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6" $DEBUG && shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6 unset RUMP_SERVER @@ -290,16 +282,16 @@ linklocal_body() unset RUMP_SERVER export RUMP_SERVER=${SOCKSRC} - atf_check -s exit:0 -o match:"add net default:" rump.route add -inet6 default \ - ${fwd_if0_lladdr}%shmif0 + atf_check -s exit:0 -o match:"add net default:" \ + rump.route add -inet6 default ${fwd_if0_lladdr}%shmif0 atf_check -s exit:0 -o ignore rump.ifconfig -w 10 $DEBUG && rump.ifconfig shmif0 - $DEBUG && dump + $DEBUG && _dump export RUMP_SERVER=${SOCKSRC} atf_check -s exit:0 -o match:"0.0% packet loss" \ - rump.ping6 -c 1 -X $TIMEOUT -n -S ${src_if0_lladdr}%shmif0 ${IP6FWD0} + rump.ping6 -c 1 -X $TIMEOUT -n -S ${src_if0_lladdr}%shmif0 ${IP6FWD0} unset RUMP_SERVER export RUMP_SERVER=${SOCKFWD} @@ -340,7 +332,7 @@ linklocal_body() linklocal_cleanup() { - $DEBUG && dump + $DEBUG && _dump $DEBUG && dump_bus cleanup_rump_servers } @@ -348,7 +340,8 @@ linklocal_cleanup() linklocal_ops_head() { - atf_set "descr" "Test for various operations to IPv6 linklocal addresses" + atf_set "descr" \ + "Test for various operations to IPv6 linklocal addresses" atf_set "require.progs" "rump_server rump.route rump.ndp" } @@ -358,7 +351,7 @@ linklocal_ops_body() setup - src_if0_lladdr=`get_lladdr ${SOCKSRC} shmif0` + src_if0_lladdr=`get_linklocal_addr ${SOCKSRC} shmif0` export RUMP_SERVER=${SOCKSRC} diff --git a/contrib/netbsd-tests/net/net/t_mtudisc.sh b/contrib/netbsd-tests/net/net/t_mtudisc.sh new file mode 100755 index 0000000..a99d652 --- /dev/null +++ b/contrib/netbsd-tests/net/net/t_mtudisc.sh @@ -0,0 +1,192 @@ +# $NetBSD: t_mtudisc.sh,v 1.8 2016/12/21 01:16:18 ozaki-r Exp $ +# +# Copyright (c) 2016 Internet Initiative Japan Inc. +# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +SOCKLOCAL=unix://commsock1 +SOCKGATEWAY=unix://commsock2 +SOCKREMOTE=unix://commsock3 +HTML_FILE=index.html + +DEBUG=${DEBUG:-false} + +atf_test_case mtudisc_basic cleanup + +mtudisc_basic_head() +{ + atf_set "descr" "Tests for IPv4 Path MTU Dicorvery basic behavior" + atf_set "require.progs" "rump_server" +} + +setup_server() +{ + local sock=$1 + local if=$2 + local bus=$3 + local ip=$4 + + rump_server_add_iface $sock $if $bus + + export RUMP_SERVER=$sock + atf_check -s exit:0 rump.ifconfig $if $ip + atf_check -s exit:0 rump.ifconfig $if up + atf_check -s exit:0 rump.ifconfig -w 10 + + $DEBUG && rump.ifconfig $if +} + +prepare_download_file() +{ + local file=$1 + local data="0123456789" + + touch $file + for i in `seq 1 512` + do + echo $data >> $file + done +} + +do_http_get() +{ + local ip=$1 + local ret=$2 + local timeout=5 + + # get the webpage + atf_check -s exit:$ret env LD_PRELOAD=/usr/lib/librumphijack.so \ + ftp -q $timeout -o ./out http://$ip/$HTML_FILE +} + +mtudisc_basic_body() +{ + local pkt= + local local_ip=10.0.0.2 + local gateway_local_ip=10.0.0.1 + local gateway_remote_ip=10.0.1.1 + local remote_ip=10.0.1.2 + local prefixlen=24 + + rump_server_start $SOCKLOCAL + rump_server_start $SOCKGATEWAY + rump_server_start $SOCKREMOTE + + # + # Setup servers + # + # [local server] [gateway server] [remote server with httpd] + # | 10.0.0.2 10.0.0.1 | | 10.0.1.1 10.0.1.2 | + # shmif0(mtu=1500) ----- shmif1(mtu=1280) shmif0(mtu=1500) ----- shmif0(mtu=1500) + # + + # Assign IP addresses + setup_server $SOCKLOCAL shmif0 bus1 $local_ip/$prefixlen + setup_server $SOCKGATEWAY shmif0 bus1 $gateway_local_ip/$prefixlen + setup_server $SOCKGATEWAY shmif1 bus2 $gateway_remote_ip/$prefixlen + setup_server $SOCKREMOTE shmif0 bus2 $remote_ip/$prefixlen + + ### Setup gateway server + export RUMP_SERVER=$SOCKGATEWAY + + # Set mtu of shmif0 to 1280 + export RUMP_SERVER=$SOCKGATEWAY + atf_check -s exit:0 rump.ifconfig shmif0 mtu 1280 + + # Enable IPv4 forwarding + atf_check -s exit:0 rump.sysctl -w -q net.inet.ip.forwarding=1 + + ### Setup remote server + export RUMP_SERVER=$SOCKREMOTE + + # Check default value + atf_check -s exit:0 -o match:"1" rump.sysctl -n net.inet.ip.mtudisc + + # Start httpd daemon + prepare_download_file $HTML_FILE + start_httpd $SOCKREMOTE $remote_ip + $DEBUG && rump.netstat -a -f inet + + # Teach the peer thar 10.0.0.2(local serer) is behind 10.0.1.1(gateway server) + atf_check -s exit:0 -o ignore rump.route add $local_ip/32 $gateway_remote_ip + + ### Setup local server + export RUMP_SERVER=$SOCKLOCAL + + # Teach the peer thar 10.0.1.2(remote serer) is behind 10.0.0.1(gateway server) + atf_check -s exit:0 -o ignore rump.route add $remote_ip/32 $gateway_local_ip + + # Don't accept fragmented packets + atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet.ip.maxfragpackets=0 + + # + # Test disabled path mtu discorvery + # + export RUMP_SERVER=$SOCKREMOTE + atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet.ip.mtudisc=0 + + # Get the webpage (expect: failed) + export RUMP_SERVER=$SOCKLOCAL + do_http_get $remote_ip 1 + $DEBUG && extract_new_packets bus2 > ./out + $DEBUG && cat ./out + + # Check path mtu size on remote server + export RUMP_SERVER=$SOCKREMOTE + atf_check -s exit:0 \ + -o match:"^10.0.0.2 +10.0.1.1 +UGHS +- +- +- +shmif0" \ + rump.netstat -nr -f inet + + # + # Test enabled path mtu discorvery + # + export RUMP_SERVER=$SOCKREMOTE + atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet.ip.mtudisc=1 + + # Get the webpage (expect: success) + export RUMP_SERVER=$SOCKLOCAL + do_http_get $remote_ip 0 + $DEBUG && extract_new_packets bus2 > ./out + $DEBUG && cat ./out + + # Check path mtu size on remote server + export RUMP_SERVER=$SOCKREMOTE + atf_check -s exit:0 \ + -o match:"^10.0.0.2 +10.0.1.1 +UGHS +- +- +1280 +shmif0" \ + rump.netstat -nr -f inet + + rump_server_destroy_ifaces +} + +mtudisc_basic_cleanup() +{ + $DEBUG && dump + stop_httpd + cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case mtudisc_basic +} diff --git a/contrib/netbsd-tests/net/net/t_mtudisc6.sh b/contrib/netbsd-tests/net/net/t_mtudisc6.sh new file mode 100755 index 0000000..93bc12e --- /dev/null +++ b/contrib/netbsd-tests/net/net/t_mtudisc6.sh @@ -0,0 +1,179 @@ +# $NetBSD: t_mtudisc6.sh,v 1.5 2016/11/25 08:51:17 ozaki-r Exp $ +# +# Copyright (c) 2016 Internet Initiative Japan Inc. +# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +SOCKLOCAL=unix://commsock1 +SOCKGATEWAY=unix://commsock2 +SOCKREMOTE=unix://commsock3 +HTML_FILE=index.html + +DEBUG=${DEBUG:-false} + +atf_test_case mtudisc6_basic cleanup + +mtudisc6_basic_head() +{ + + atf_set "descr" "Tests for IPv6 Path MTU Dicorvery basic behavior" + atf_set "require.progs" "rump_server" +} + +setup_server() +{ + local sock=$1 + local if=$2 + local bus=$3 + local ip=$4 + + rump_server_add_iface $sock $if $bus + + export RUMP_SERVER=$sock + atf_check -s exit:0 rump.ifconfig $if inet6 $ip + atf_check -s exit:0 rump.ifconfig $if up + atf_check -s exit:0 rump.ifconfig -w 10 + + $DEBUG && rump.ifconfig $if +} + +prepare_download_file() +{ + local file=$1 + local data="0123456789" + + touch $file + for i in `seq 1 512` + do + echo $data >> $file + done +} + +do_http_get() +{ + local ip=$1 + local ret=$2 + local timeout=5 + + # get the webpage + atf_check -s exit:$ret env LD_PRELOAD=/usr/lib/librumphijack.so \ + ftp -q $timeout -o ./out "http://[$ip]/$HTML_FILE" +} + +mtudisc6_basic_body() +{ + local pkt= + local local_ip=fc00:0:0:1::2 + local gateway_local_ip=fc00:0:0:1::1 + local gateway_remote_ip=fc00:0:0:2::1 + local remote_ip=fc00:0:0:2::2 + local prefixlen=64 + + rump_server_start $SOCKLOCAL netinet6 + rump_server_start $SOCKGATEWAY netinet6 + rump_server_start $SOCKREMOTE netinet6 + + # + # Setup servers + # + # [local server] [gateway server] [remote server] + # | | | | + # shmif0(1500) -- shmif1(1280) shmif0(1500) -- shmif0(1500) + # + + # Assign IP addresses + setup_server $SOCKLOCAL shmif0 bus1 $local_ip/$prefixlen + setup_server $SOCKGATEWAY shmif0 bus1 $gateway_local_ip/$prefixlen + setup_server $SOCKGATEWAY shmif1 bus2 $gateway_remote_ip/$prefixlen + setup_server $SOCKREMOTE shmif0 bus2 $remote_ip/$prefixlen + + ### Setup gateway server + export RUMP_SERVER=$SOCKGATEWAY + + # Set MTU of shmif0 to 1280 + export RUMP_SERVER=$SOCKGATEWAY + atf_check -s exit:0 rump.ifconfig shmif0 mtu 1280 + + # Enable IPv6 forwarding + atf_check -s exit:0 rump.sysctl -w -q net.inet6.ip6.forwarding=1 + + ### Setup remote server + export RUMP_SERVER=$SOCKREMOTE + + # Start httpd daemon + prepare_download_file $HTML_FILE + start_httpd $SOCKREMOTE $remote_ip + $DEBUG && rump.netstat -a + + # Teach the peer that local serer is behind gateway server + atf_check -s exit:0 -o ignore \ + rump.route add -inet6 $local_ip/128 $gateway_remote_ip + + # Check path MTU size on remote server + atf_check -s exit:0 \ + -o match:"^$local_ip +$gateway_remote_ip +UGHS +- +- +- +shmif0" \ + rump.netstat -nr -f inet6 + + ### Setup local server + export RUMP_SERVER=$SOCKLOCAL + + # Teach the peer that remote serer is behind gateway server + atf_check -s exit:0 -o ignore \ + rump.route add -inet6 $remote_ip/128 $gateway_local_ip + + # Don't accept fragmented packets + atf_check -s exit:0 -o ignore \ + rump.sysctl -w -q net.inet6.ip6.maxfragpackets=0 + + # + # Test enabled path MTU discorvery + # + # Get the webpage (expect: success) + export RUMP_SERVER=$SOCKLOCAL + do_http_get $remote_ip 0 + $DEBUG && extract_new_packets bus2 > ./out + $DEBUG && cat ./out + + # Check path MTU size on remote server + export RUMP_SERVER=$SOCKREMOTE + atf_check -s exit:0 \ + -o match:"^$local_ip +$gateway_remote_ip +UGHS +- +- +1280 +shmif0" \ + rump.netstat -nr -f inet6 + + rump_server_destroy_ifaces +} + +mtudisc6_basic_cleanup() +{ + + $DEBUG && dump + stop_httpd + cleanup +} + +atf_init_test_cases() +{ + + atf_add_test_case mtudisc6_basic +} diff --git a/contrib/netbsd-tests/net/net/t_ping6_opts.sh b/contrib/netbsd-tests/net/net/t_ping6_opts.sh new file mode 100755 index 0000000..e2e774e --- /dev/null +++ b/contrib/netbsd-tests/net/net/t_ping6_opts.sh @@ -0,0 +1,380 @@ +# $NetBSD: t_ping6_opts.sh,v 1.8 2016/11/25 08:51:17 ozaki-r Exp $ +# +# Copyright (c) 2016 Internet Initiative Japan Inc. +# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +SOCKSRC=unix://commsock1 +SOCKFWD=unix://commsock2 +SOCKDST=unix://commsock3 +IP6SRC=fc00:0:0:1::2 +IP6SRCGW=fc00:0:0:1::1 +IP6DSTGW=fc00:0:0:2::1 +IP6DST=fc00:0:0:2::2 +BUS_SRCGW=bus1 +BUS_DSTGW=bus2 + +IP6SRC2=fc00:0:0:1::3 +IP6SRCGW2=fc00:0:0:1::254 + +DEBUG=${DEBUG:-false} +TIMEOUT=1 + +# +# Utility functions +# +setup_endpoint() +{ + local sock=${1} + local addr=${2} + local bus=${3} + local gw=${4} + + rump_server_add_iface $sock shmif0 $bus + + export RUMP_SERVER=${sock} + atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${addr} + atf_check -s exit:0 -o ignore rump.route add -inet6 default ${gw} + atf_check -s exit:0 rump.ifconfig shmif0 up + atf_check -s exit:0 rump.ifconfig -w 10 + + if $DEBUG; then + rump.ifconfig shmif0 + rump.netstat -nr + fi +} + +setup_forwarder() +{ + + rump_server_add_iface $SOCKFWD shmif0 $BUS_SRCGW + rump_server_add_iface $SOCKFWD shmif1 $BUS_DSTGW + + export RUMP_SERVER=$SOCKFWD + + atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6SRCGW} + atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6DSTGW} + + atf_check -s exit:0 rump.ifconfig shmif0 up + atf_check -s exit:0 rump.ifconfig shmif1 up + atf_check -s exit:0 rump.ifconfig -w 10 + + if $DEBUG; then + rump.netstat -nr + rump.sysctl net.inet6.ip6.forwarding + fi +} + +setup_forwarding6() +{ + export RUMP_SERVER=$SOCKFWD + atf_check -s exit:0 -o ignore rump.sysctl -w net.inet6.ip6.forwarding=1 +} + +setup6() +{ + + rump_server_start $SOCKSRC netinet6 + rump_server_start $SOCKFWD netinet6 + rump_server_start $SOCKDST netinet6 + + setup_endpoint $SOCKSRC $IP6SRC $BUS_SRCGW $IP6SRCGW + setup_endpoint $SOCKDST $IP6DST $BUS_DSTGW $IP6DSTGW + setup_forwarder +} + +check_echo_request_pkt() +{ + local pkt="$1 > $2: .+ echo request" + + extract_new_packets $BUS_SRCGW > ./out + $DEBUG && echo $pkt + $DEBUG && cat ./out + atf_check -s exit:0 -o match:"$pkt" cat ./out +} + +check_echo_request_pkt_with_macaddr() +{ + local pkt="$1 > $2, .+ $3 > $4: .+ echo request" + + extract_new_packets $BUS_SRCGW > ./out + $DEBUG && echo $pkt + $DEBUG && cat ./out + atf_check -s exit:0 -o match:"$pkt" cat ./out +} + +check_echo_request_pkt_with_macaddr_and_rthdr0() +{ + local pkt= + + pkt="$1 > $2, .+ $3 > $4:" + pkt="$pkt srcrt \\(len=2, type=0, segleft=1, \\[0\\]$5\\)" + pkt="$pkt .+ echo request" + + extract_new_packets $BUS_SRCGW > ./out + $DEBUG && echo $pkt + $DEBUG && cat ./out + atf_check -s exit:0 -o match:"$pkt" cat ./out +} + +# +# Tests +# +atf_test_case ping6_opts_sourceaddr cleanup +ping6_opts_sourceaddr_head() +{ + + atf_set "descr" "tests of ping6 -S option" + atf_set "require.progs" "rump_server" +} + +ping6_opts_sourceaddr_body() +{ + + setup6 + setup_forwarding6 + + export RUMP_SERVER=$SOCKSRC + atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST + check_echo_request_pkt $IP6SRC $IP6DST + + atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6SRC2 + atf_check -s exit:0 rump.ifconfig -w 10 + + atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST + check_echo_request_pkt $IP6SRC $IP6DST + + # ping6 -S + atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \ + -S $IP6SRC $IP6DST + check_echo_request_pkt $IP6SRC $IP6DST + + atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \ + -S $IP6SRC2 $IP6DST + check_echo_request_pkt $IP6SRC2 $IP6DST + + rump_server_destroy_ifaces +} + +ping6_opts_sourceaddr_cleanup() +{ + + $DEBUG && dump + cleanup +} + +atf_test_case ping6_opts_interface cleanup +ping6_opts_interface_head() +{ + + atf_set "descr" "tests of ping6 -I option" + atf_set "require.progs" "rump_server" +} + +ping6_opts_interface_body() +{ + local shmif0_lladdr= + local shmif1_lladdr= + local gw_lladdr= + + setup6 + setup_forwarding6 + + shmif0_lladdr=$(get_linklocal_addr ${SOCKSRC} shmif0) + gw_lladdr=$(get_linklocal_addr ${SOCKFWD} shmif0) + + export RUMP_SERVER=$SOCKSRC + atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $gw_lladdr + check_echo_request_pkt $shmif0_lladdr $gw_lladdr + + rump_server_add_iface $SOCKSRC shmif1 $BUS_SRCGW + atf_check -s exit:0 rump.ifconfig shmif1 up + atf_check -s exit:0 rump.ifconfig -w 10 + shmif1_lladdr=$(get_linklocal_addr ${SOCKSRC} shmif1) + + atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $gw_lladdr + check_echo_request_pkt $shmif0_lladdr $gw_lladdr + + # ping6 -I + atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \ + -I shmif0 $gw_lladdr + check_echo_request_pkt $shmif0_lladdr $gw_lladdr + + atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \ + -I shmif1 $gw_lladdr + check_echo_request_pkt $shmif1_lladdr $gw_lladdr + + rump_server_destroy_ifaces +} + +ping6_opts_interface_cleanup() +{ + + $DEBUG && dump + cleanup +} + +atf_test_case ping6_opts_gateway cleanup +ping6_opts_gateway_head() +{ + + atf_set "descr" "tests of ping6 -g option" + atf_set "require.progs" "rump_server" +} + +ping6_opts_gateway_body() +{ + local my_macaddr= + local gw_shmif0_macaddr= + local gw_shmif2_macaddr= + + setup6 + setup_forwarding6 + + my_macaddr=$(get_macaddr ${SOCKSRC} shmif0) + gw_shmif0_macaddr=$(get_macaddr ${SOCKFWD} shmif0) + + export RUMP_SERVER=$SOCKSRC + atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST + check_echo_request_pkt_with_macaddr \ + $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST + + rump_server_add_iface $SOCKFWD shmif2 $BUS_SRCGW + export RUMP_SERVER=$SOCKFWD + atf_check -s exit:0 rump.ifconfig shmif2 inet6 $IP6SRCGW2 + atf_check -s exit:0 rump.ifconfig -w 10 + gw_shmif2_macaddr=$(get_macaddr ${SOCKFWD} shmif2) + + export RUMP_SERVER=$SOCKSRC + atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST + check_echo_request_pkt_with_macaddr \ + $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST + + # ping6 -g + atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \ + -g $IP6SRCGW $IP6DST + check_echo_request_pkt_with_macaddr \ + $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST + + atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \ + -g $IP6SRCGW2 $IP6DST + check_echo_request_pkt_with_macaddr \ + $my_macaddr $gw_shmif2_macaddr $IP6SRC $IP6DST + + rump_server_destroy_ifaces +} + +ping6_opts_gateway_cleanup() +{ + + $DEBUG && dump + cleanup +} + +atf_test_case ping6_opts_hops cleanup +ping6_opts_hops_head() +{ + + atf_set "descr" "tests of ping6 hops (Type 0 Routing Header)" + atf_set "require.progs" "rump_server" +} + +ping6_opts_hops_body() +{ + local my_macaddr= + local gw_shmif0_macaddr= + local gw_shmif2_macaddr= + + setup6 + setup_forwarding6 + + my_macaddr=$(get_macaddr ${SOCKSRC} shmif0) + gw_shmif0_macaddr=$(get_macaddr ${SOCKFWD} shmif0) + + export RUMP_SERVER=$SOCKSRC + atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST + check_echo_request_pkt_with_macaddr \ + $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST + + rump_server_add_iface $SOCKFWD shmif2 $BUS_SRCGW + export RUMP_SERVER=$SOCKFWD + atf_check -s exit:0 rump.ifconfig shmif2 inet6 $IP6SRCGW2 + atf_check -s exit:0 rump.ifconfig -w 10 + gw_shmif2_macaddr=$(get_macaddr ${SOCKFWD} shmif2) + + export RUMP_SERVER=$SOCKSRC + atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST + check_echo_request_pkt_with_macaddr \ + $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST + + # ping6 hops + + # ping6 fails expectedly because the kernel doesn't support + # to receive packets with type 0 routing headers, but we can + # check whether a sent packet is correct. + atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \ + $IP6SRCGW $IP6DST + check_echo_request_pkt_with_macaddr_and_rthdr0 \ + $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6SRCGW $IP6DST + + atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \ + $IP6SRCGW2 $IP6DST + check_echo_request_pkt_with_macaddr_and_rthdr0 \ + $my_macaddr $gw_shmif2_macaddr $IP6SRC $IP6SRCGW2 $IP6DST + + # ping6 -g hops + atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \ + -g $IP6SRCGW $IP6SRCGW $IP6DST + check_echo_request_pkt_with_macaddr_and_rthdr0 \ + $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6SRCGW $IP6DST + + atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \ + -g $IP6SRCGW2 $IP6SRCGW2 $IP6DST + check_echo_request_pkt_with_macaddr_and_rthdr0 \ + $my_macaddr $gw_shmif2_macaddr $IP6SRC $IP6SRCGW2 $IP6DST + + # ping6 -g hops, but different nexthops (is it valid?) + atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \ + -g $IP6SRCGW $IP6SRCGW2 $IP6DST + check_echo_request_pkt_with_macaddr_and_rthdr0 \ + $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6SRCGW2 $IP6DST + + rump_server_destroy_ifaces +} + +ping6_opts_hops_cleanup() +{ + + $DEBUG && dump + cleanup +} + +atf_init_test_cases() +{ + + atf_add_test_case ping6_opts_sourceaddr + atf_add_test_case ping6_opts_interface + atf_add_test_case ping6_opts_gateway + atf_add_test_case ping6_opts_hops +} diff --git a/contrib/netbsd-tests/net/net_common.sh b/contrib/netbsd-tests/net/net_common.sh new file mode 100755 index 0000000..df21a88 --- /dev/null +++ b/contrib/netbsd-tests/net/net_common.sh @@ -0,0 +1,314 @@ +# $NetBSD: net_common.sh,v 1.11 2017/01/10 05:55:34 ozaki-r Exp $ +# +# Copyright (c) 2016 Internet Initiative Japan Inc. +# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# + +# +# Common utility functions for tests/net +# + +HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes" + +extract_new_packets() +{ + local bus=$1 + local old=./.__old + + if [ ! -f $old ]; then + old=/dev/null + fi + + shmif_dumpbus -p - $bus 2>/dev/null| \ + tcpdump -n -e -r - 2>/dev/null > ./.__new + diff -u $old ./.__new |grep '^+' |cut -d '+' -f 2 > ./.__diff + mv -f ./.__new ./.__old + cat ./.__diff +} + +check_route() +{ + local target=$1 + local gw=$2 + local flags=${3:-\.\+} + local ifname=${4:-\.\+} + + target=$(echo $target |sed 's/\./\\./g') + if [ "$gw" = "" ]; then + gw=".+" + else + gw=$(echo $gw |sed 's/\./\\./g') + fi + + atf_check -s exit:0 -e ignore \ + -o match:"^$target +$gw +$flags +- +- +.+ +$ifname" \ + rump.netstat -rn +} + +check_route_flags() +{ + + check_route "$1" "" "$2" "" +} + +check_route_gw() +{ + + check_route "$1" "$2" "" "" +} + +check_route_no_entry() +{ + local target=$(echo $1 |sed 's/\./\\./g') + + atf_check -s exit:0 -e ignore -o not-match:"^$target" \ + rump.netstat -rn +} + +get_linklocal_addr() +{ + + export RUMP_SERVER=${1} + rump.ifconfig ${2} inet6 | + awk "/fe80/ {sub(/%$2/, \"\"); sub(/\\/[0-9]*/, \"\"); print \$2;}" + unset RUMP_SERVER + + return 0 +} + +get_macaddr() +{ + + env RUMP_SERVER=${1} \ + rump.ifconfig ${2} |awk '/address/ {print $2;}' +} + +HTTPD_PID=./.__httpd.pid +start_httpd() +{ + local sock=$1 + local ip=$2 + local backup=$RUMP_SERVER + + export RUMP_SERVER=$sock + + # start httpd in daemon mode + atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \ + /usr/libexec/httpd -P $HTTPD_PID -i $ip -b -s $(pwd) + + export RUMP_SERVER=$backup + + sleep 3 +} + +stop_httpd() +{ + + if [ -f $HTTPD_PID ]; then + kill -9 $(cat $HTTPD_PID) + rm -f $HTTPD_PID + sleep 1 + fi +} + +BASIC_LIBS="-lrumpnet -lrumpnet_net -lrumpnet_netinet \ + -lrumpnet_shmif -lrumpdev" +FS_LIBS="$BASIC_LIBS -lrumpvfs -lrumpfs_ffs" + +# We cannot keep variables between test phases, so need to store in files +_rump_server_socks=./.__socks +_rump_server_ifaces=./.__ifaces +_rump_server_buses=./.__buses + +_rump_server_start_common() +{ + local sock=$1 + local libs= + + shift 1 + libs="$*" + + atf_check -s exit:0 rump_server $libs $sock + + echo $sock >> $_rump_server_socks + $DEBUG && cat $_rump_server_socks +} + +rump_server_start() +{ + local sock=$1 + local _libs= + local libs="$BASIC_LIBS" + + shift 1 + _libs="$*" + + for lib in $_libs; do + libs="$libs -lrumpnet_$lib" + done + + _rump_server_start_common $sock $libs + + return 0 +} + +rump_server_fs_start() +{ + local sock=$1 + local _libs= + local libs="$FS_LIBS" + + shift 1 + _libs="$*" + + for lib in $_libs; do + libs="$libs -lrumpnet_$lib" + done + + _rump_server_start_common $sock $libs + + return 0 +} + +rump_server_add_iface() +{ + local sock=$1 + local ifname=$2 + local bus=$3 + local backup=$RUMP_SERVER + + export RUMP_SERVER=$sock + atf_check -s exit:0 rump.ifconfig $ifname create + atf_check -s exit:0 rump.ifconfig $ifname linkstr $bus + export RUMP_SERVER=$backup + + echo $sock $ifname >> $_rump_server_ifaces + $DEBUG && cat $_rump_server_ifaces + + echo $bus >> $_rump_server_buses + cat $_rump_server_buses |sort -u >./.__tmp + mv -f ./.__tmp $_rump_server_buses + $DEBUG && cat $_rump_server_buses + + return 0 +} + +rump_server_destroy_ifaces() +{ + local backup=$RUMP_SERVER + + $DEBUG && cat $_rump_server_ifaces + + # Try to dump states before destroying interfaces + for sock in $(cat $_rump_server_socks); do + export RUMP_SERVER=$sock + atf_check -s exit:0 -o ignore rump.ifconfig + atf_check -s exit:0 -o ignore rump.netstat -nr + # XXX still need hijacking + atf_check -s exit:0 -o ignore $HIJACKING rump.netstat -i -a + atf_check -s exit:0 -o ignore rump.arp -na + atf_check -s exit:0 -o ignore rump.ndp -na + atf_check -s exit:0 -o ignore $HIJACKING ifmcstat + done + + # XXX using pipe doesn't work. See PR bin/51667 + #cat $_rump_server_ifaces | while read sock ifname; do + while read sock ifname; do + export RUMP_SERVER=$sock + if rump.ifconfig -l |grep -q $ifname; then + atf_check -s exit:0 rump.ifconfig $ifname destroy + fi + atf_check -s exit:0 -o ignore rump.ifconfig + done < $_rump_server_ifaces + export RUMP_SERVER=$backup + + return 0 +} + +rump_server_halt_servers() +{ + local backup=$RUMP_SERVER + + $DEBUG && cat $_rump_server_socks + for sock in $(cat $_rump_server_socks); do + env RUMP_SERVER=$sock rump.halt + done + export RUMP_SERVER=$backup + + return 0 +} + +rump_server_dump_servers() +{ + local backup=$RUMP_SERVER + + $DEBUG && cat $_rump_server_socks + for sock in $(cat $_rump_server_socks); do + echo "### Dumping $sock" + export RUMP_SERVER=$sock + rump.ifconfig + rump.netstat -nr + # XXX still need hijacking + $HIJACKING rump.netstat -i -a + rump.arp -na + rump.ndp -na + $HIJACKING ifmcstat + $HIJACKING dmesg + done + export RUMP_SERVER=$backup + + if [ -f rump_server.core ]; then + gdb -ex bt /usr/bin/rump_server rump_server.core + strings rump_server.core |grep panic + fi + return 0 +} + +rump_server_dump_buses() +{ + + if [ ! -f $_rump_server_buses ]; then + return 0 + fi + + $DEBUG && cat $_rump_server_buses + for bus in $(cat $_rump_server_buses); do + echo "### Dumping $bus" + shmif_dumpbus -p - $bus 2>/dev/null| tcpdump -n -e -r - + done + return 0 +} + +cleanup() +{ + + rump_server_halt_servers +} + +dump() +{ + + rump_server_dump_servers + rump_server_dump_buses +} diff --git a/contrib/netbsd-tests/net/route/t_change.sh b/contrib/netbsd-tests/net/route/t_change.sh index 669c9f3..260cad0 100755 --- a/contrib/netbsd-tests/net/route/t_change.sh +++ b/contrib/netbsd-tests/net/route/t_change.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_change.sh,v 1.8 2016/08/10 23:00:39 roy Exp $ +# $NetBSD: t_change.sh,v 1.9 2016/11/07 05:25:37 ozaki-r Exp $ # # Copyright (c) 2011 The NetBSD Foundation, Inc. # All rights reserved. @@ -30,7 +30,7 @@ netserver=\ -lrumpnet_netinet -lrumpnet_shmif" export RUMP_SERVER=unix://commsock -DEBUG=false +DEBUG=${DEBUG:-false} atf_test_case route_change_reject2blackhole cleanup route_change_reject2blackhole_head() diff --git a/contrib/netbsd-tests/net/route/t_flags.sh b/contrib/netbsd-tests/net/route/t_flags.sh index 26625bb..457e3f5 100755 --- a/contrib/netbsd-tests/net/route/t_flags.sh +++ b/contrib/netbsd-tests/net/route/t_flags.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_flags.sh,v 1.11 2016/08/10 23:00:39 roy Exp $ +# $NetBSD: t_flags.sh,v 1.15 2016/12/21 02:46:08 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,27 +25,24 @@ # POSSIBILITY OF SUCH DAMAGE. # -netserver=\ -"rump_server -lrumpdev -lrumpnet -lrumpnet_net -lrumpnet_netinet \ - -lrumpnet_shmif" SOCK_LOCAL=unix://commsock1 SOCK_PEER=unix://commsock2 SOCK_GW=unix://commsock3 BUS=bus1 BUS2=bus2 -DEBUG=false +DEBUG=${DEBUG:-false} setup_local() { - atf_check -s exit:0 ${netserver} ${SOCK_LOCAL} + rump_server_start $SOCK_LOCAL + rump_server_add_iface $SOCK_LOCAL shmif0 $BUS export RUMP_SERVER=$SOCK_LOCAL - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS} atf_check -s exit:0 -o ignore rump.ifconfig shmif0 10.0.0.2/24 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up + atf_check -s exit:0 -o ignore rump.ifconfig -w 10 $DEBUG && rump.ifconfig $DEBUG && rump.netstat -rn -f inet @@ -54,13 +51,13 @@ setup_local() setup_peer() { - atf_check -s exit:0 ${netserver} ${SOCK_PEER} + rump_server_start $SOCK_PEER + rump_server_add_iface $SOCK_PEER shmif0 $BUS export RUMP_SERVER=$SOCK_PEER - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS} atf_check -s exit:0 -o ignore rump.ifconfig shmif0 10.0.0.1/24 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up + atf_check -s exit:0 -o ignore rump.ifconfig -w 10 $DEBUG && rump.ifconfig $DEBUG && rump.netstat -rn -f inet @@ -69,16 +66,14 @@ setup_peer() setup_gw() { - atf_check -s exit:0 ${netserver} ${SOCK_GW} + rump_server_start $SOCK_GW + rump_server_add_iface $SOCK_GW shmif0 $BUS + rump_server_add_iface $SOCK_GW shmif1 $BUS2 export RUMP_SERVER=$SOCK_GW - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS} atf_check -s exit:0 -o ignore rump.ifconfig shmif0 10.0.0.254/24 atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up - atf_check -s exit:0 -o ignore rump.ifconfig shmif1 create - atf_check -s exit:0 -o ignore rump.ifconfig shmif1 linkstr ${BUS2} atf_check -s exit:0 -o ignore rump.ifconfig shmif1 10.0.2.1/24 atf_check -s exit:0 -o ignore rump.ifconfig shmif1 alias 10.0.2.2/24 atf_check -s exit:0 -o ignore rump.ifconfig shmif1 up @@ -91,46 +86,13 @@ setup_gw() $DEBUG && rump.netstat -rn -f inet } -teardown_gw() -{ - - env RUMP_SERVER=$SOCK_GW rump.halt -} - -check_entry_flags() -{ - local ip=$(echo $1 |sed 's/\./\\./g') - local flags=$2 - - atf_check -s exit:0 -o match:" $flags " -e ignore -x \ - "rump.netstat -rn -f inet | grep ^'$ip'" -} - -check_entry_gw() -{ - local ip=$(echo $1 |sed 's/\./\\./g') - local gw=$2 - - atf_check -s exit:0 -o match:" $gw " -e ignore -x \ - "rump.netstat -rn -f inet | grep ^'$ip'" -} - -check_entry_fail() -{ - ip=$(echo $1 |sed 's/\./\\./g') - flags=$2 # Not used currently - - atf_check -s not-exit:0 -e ignore -x \ - "rump.netstat -rn -f inet | grep ^'$ip'" -} - test_lo() { export RUMP_SERVER=$SOCK_LOCAL # Up, Host, local - check_entry_flags 127.0.0.1 UHl + check_route_flags 127.0.0.1 UHl } test_connected() @@ -139,10 +101,10 @@ test_connected() export RUMP_SERVER=$SOCK_LOCAL # Up, Host, LLINFO, local - check_entry_flags 10.0.0.2 UHl + check_route_flags 10.0.0.2 UHl # Up, Cloning - check_entry_flags 10.0.0/24 UC + check_route_flags 10.0.0/24 UC } test_default_gateway() @@ -154,7 +116,7 @@ test_default_gateway() $DEBUG && rump.netstat -rn -f inet # Up, Gateway, Static - check_entry_flags default UGS + check_route_flags default UGS } test_static() @@ -167,14 +129,14 @@ test_static() $DEBUG && rump.netstat -rn -f inet # Up, Gateway, Host, Static - check_entry_flags 10.0.1.1 UGHS + check_route_flags 10.0.1.1 UGHS # Static route to network atf_check -s exit:0 -o ignore rump.route add -net 10.0.2.0/24 10.0.0.1 $DEBUG && rump.netstat -rn -f inet # Up, Gateway, Static - check_entry_flags 10.0.2/24 UGS + check_route_flags 10.0.2/24 UGS } test_blackhole() @@ -193,14 +155,14 @@ test_blackhole() $DEBUG && rump.netstat -rn -f inet # Up, Gateway, Blackhole, Static - check_entry_flags 10.0.0/24 UGBS + check_route_flags 10.0.0/24 UGBS atf_check -s not-exit:0 -o match:'100.0% packet loss' \ rump.ping -n -w 1 -c 1 10.0.0.1 $DEBUG && rump.netstat -rn -f inet # Shouldn't be created - check_entry_fail 10.0.0.1 UH + check_route_no_entry 10.0.0.1 } test_reject() @@ -215,14 +177,14 @@ test_reject() $DEBUG && rump.netstat -rn -f inet # Up, Gateway, Reject, Static - check_entry_flags 10.0.0/24 UGRS + check_route_flags 10.0.0/24 UGRS atf_check -s not-exit:0 -o ignore -e match:'No route to host' \ rump.ping -n -w 1 -c 1 10.0.0.1 $DEBUG && rump.netstat -rn -f inet # Shouldn't be created - check_entry_fail 10.0.0.1 UH + check_route_no_entry 10.0.0.1 # Gateway is lo0 (RTF_GATEWAY) @@ -234,14 +196,14 @@ test_reject() $DEBUG && rump.netstat -rn -f inet # Up, Gateway, Reject, Static - check_entry_flags 10.0.0/24 UGRS + check_route_flags 10.0.0/24 UGRS atf_check -s not-exit:0 -o ignore -e match:'Network is unreachable' \ rump.ping -n -w 1 -c 1 10.0.0.1 $DEBUG && rump.netstat -rn -f inet # Shouldn't be created - check_entry_fail 10.0.0.1 UH + check_route_no_entry 10.0.0.1 # Gateway is lo0 (RTF_HOST) @@ -253,7 +215,7 @@ test_reject() $DEBUG && rump.netstat -rn -f inet # Up, Host, Reject, Static - check_entry_flags 10.0.0.1 UHRS + check_route_flags 10.0.0.1 UHRS atf_check -s not-exit:0 -o ignore -e match:'No route to host' \ rump.ping -n -w 1 -c 1 10.0.0.1 @@ -278,7 +240,7 @@ test_icmp_redirect() export RUMP_SERVER=$SOCK_PEER atf_check -s exit:0 -o ignore rump.route add -net 10.0.2.0/24 10.0.0.254 # Up, Gateway, Static - check_entry_flags 10.0.2/24 UGS + check_route_flags 10.0.2/24 UGS # # Setup the default gateway to the peer, 10.0.0.1 @@ -286,15 +248,15 @@ test_icmp_redirect() export RUMP_SERVER=$SOCK_LOCAL atf_check -s exit:0 -o ignore rump.route add default 10.0.0.1 # Up, Gateway, Static - check_entry_flags default UGS + check_route_flags default UGS # Try ping 10.0.2.1 atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 10.0.2.1 $DEBUG && rump.netstat -rn -f inet # Up, Gateway, Host, Dynamic - check_entry_flags 10.0.2.1 UGHD - check_entry_gw 10.0.2.1 10.0.0.254 + check_route_flags 10.0.2.1 UGHD + check_route_gw 10.0.2.1 10.0.0.254 export RUMP_SERVER=$SOCK_PEER $DEBUG && rump.netstat -rn -f inet @@ -307,18 +269,16 @@ test_icmp_redirect() export RUMP_SERVER=$SOCK_LOCAL atf_check -s exit:0 -o ignore rump.route add 10.0.2.2 10.0.0.1 # Up, Gateway, Host, Static - check_entry_flags 10.0.2.2 UGHS - check_entry_gw 10.0.2.2 10.0.0.1 + check_route_flags 10.0.2.2 UGHS + check_route_gw 10.0.2.2 10.0.0.1 # Try ping 10.0.2.2 atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 10.0.2.2 $DEBUG && rump.netstat -rn -f inet # Up, Gateway, Host, Modified, Static - check_entry_flags 10.0.2.2 UGHMS - check_entry_gw 10.0.2.2 10.0.0.254 - - teardown_gw + check_route_flags 10.0.2.2 UGHMS + check_route_gw 10.0.2.2 10.0.0.254 } test_announce() @@ -332,19 +292,11 @@ test_announce() $DEBUG && rump.netstat -rn -f inet # Up, Gateway, Static, proxy - check_entry_flags 10.0.0/24 UGSp + check_route_flags 10.0.0/24 UGSp # TODO test its behavior } -cleanup() -{ - $DEBUG && /usr/bin/shmif_dumpbus -p - $BUS 2>/dev/null | \ - /usr/sbin/tcpdump -n -e -r - - env RUMP_SERVER=$SOCK_LOCAL rump.halt - env RUMP_SERVER=$SOCK_PEER rump.halt -} - add_test() { local name=$1 @@ -359,8 +311,10 @@ add_test() setup_local; \ setup_peer; \ test_${name}; \ + rump_server_destroy_ifaces; \ }; \ route_flags_${name}_cleanup() { \ + $DEBUG && dump; \ cleanup; \ }" atf_add_test_case "route_flags_${name}" diff --git a/contrib/netbsd-tests/net/route/t_flags6.sh b/contrib/netbsd-tests/net/route/t_flags6.sh index 20b800e..e570829 100755 --- a/contrib/netbsd-tests/net/route/t_flags6.sh +++ b/contrib/netbsd-tests/net/route/t_flags6.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_flags6.sh,v 1.7 2016/08/10 23:00:39 roy Exp $ +# $NetBSD: t_flags6.sh,v 1.12 2016/12/21 02:46:08 ozaki-r Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -25,9 +25,6 @@ # POSSIBILITY OF SUCH DAMAGE. # -RUMP_OPTS="-lrumpdev -lrumpnet -lrumpnet_net" -RUMP_OPTS="$RUMP_OPTS -lrumpnet_netinet -lrumpnet_netinet6" -RUMP_OPTS="$RUMP_OPTS -lrumpnet_shmif" SOCK_LOCAL=unix://commsock1 SOCK_PEER=unix://commsock2 SOCK_GW=unix://commsock3 @@ -37,18 +34,18 @@ BUS2=bus2 IP6_LOCAL=fc00::2 IP6_PEER=fc00::1 -DEBUG=false +DEBUG=${DEBUG:-false} setup_local() { - atf_check -s exit:0 rump_server ${RUMP_OPTS} ${SOCK_LOCAL} + rump_server_start $SOCK_LOCAL netinet6 + rump_server_add_iface $SOCK_LOCAL shmif0 $BUS export RUMP_SERVER=$SOCK_LOCAL - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS} atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $IP6_LOCAL atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up + atf_check -s exit:0 -o ignore rump.ifconfig -w 10 $DEBUG && rump.ifconfig $DEBUG && rump.netstat -rn -f inet6 @@ -57,55 +54,28 @@ setup_local() setup_peer() { - atf_check -s exit:0 rump_server ${RUMP_OPTS} ${SOCK_PEER} + rump_server_start $SOCK_PEER netinet6 + rump_server_add_iface $SOCK_PEER shmif0 $BUS export RUMP_SERVER=$SOCK_PEER - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create - atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS} atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $IP6_PEER atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up + atf_check -s exit:0 -o ignore rump.ifconfig -w 10 $DEBUG && rump.ifconfig $DEBUG && rump.netstat -rn -f inet6 } -check_entry_flags() -{ - local ip=$(echo $1 |sed 's/\./\\./g') - local flags=$2 - - atf_check -s exit:0 -o match:" $flags " -e ignore -x \ - "rump.netstat -rn -f inet6 | grep ^'$ip'" -} - -check_entry_gw() -{ - local ip=$(echo $1 |sed 's/\./\\./g') - local gw=$2 - - atf_check -s exit:0 -o match:" $gw " -e ignore -x \ - "rump.netstat -rn -f inet6 | grep ^'$ip'" -} - -check_entry_fail() -{ - ip=$(echo $1 |sed 's/\./\\./g') - flags=$2 # Not used currently - - atf_check -s not-exit:0 -e ignore -x \ - "rump.netstat -rn -f inet6 | grep ^'$ip'" -} - test_lo6() { export RUMP_SERVER=$SOCK_LOCAL # Up, Host, local - check_entry_flags fe80::1 UHl + check_route_flags fe80::1 UHl - # Up, Host - check_entry_flags ::1 UH + # Up, Host, local + check_route_flags ::1 UHl } test_connected6() @@ -114,10 +84,10 @@ test_connected6() export RUMP_SERVER=$SOCK_LOCAL # Up, Host, local - check_entry_flags $IP6_LOCAL UHl + check_route_flags $IP6_LOCAL UHl # Up, Connected - check_entry_flags fc00::/64 UC + check_route_flags fc00::/64 UC } test_default_gateway6() @@ -129,7 +99,7 @@ test_default_gateway6() $DEBUG && rump.netstat -rn -f inet6 # Up, Gateway, Static - check_entry_flags default UGS + check_route_flags default UGS } test_static6() @@ -143,7 +113,7 @@ test_static6() $DEBUG && rump.netstat -rn -f inet6 # Up, Gateway, Host, Static - check_entry_flags fc00::1:1 UGHS + check_route_flags fc00::1:1 UGHS # Static route to network atf_check -s exit:0 -o ignore \ @@ -151,7 +121,7 @@ test_static6() $DEBUG && rump.netstat -rn -f inet6 # Up, Gateway, Static - check_entry_flags fc00::/24 UGS + check_route_flags fc00::/24 UGS } test_blackhole6() @@ -171,14 +141,14 @@ test_blackhole6() $DEBUG && rump.netstat -rn -f inet6 # Up, Gateway, Blackhole, Static - check_entry_flags fc00::/64 UGBS + check_route_flags fc00::/64 UGBS atf_check -s not-exit:0 -o match:'100.0% packet loss' \ rump.ping6 -n -X 1 -c 1 $IP6_PEER $DEBUG && rump.netstat -rn -f inet6 # Shouldn't be created - check_entry_fail $IP6_PEER UH + check_route_no_entry $IP6_PEER } test_reject6() @@ -195,14 +165,14 @@ test_reject6() $DEBUG && rump.netstat -rn -f inet6 # Up, Gateway, Reject, Static - check_entry_flags fc00::/64 UGRS + check_route_flags fc00::/64 UGRS atf_check -s not-exit:0 -o ignore -e match:'No route to host' \ rump.ping6 -n -X 1 -c 1 $IP6_PEER $DEBUG && rump.netstat -rn -f inet6 # Shouldn't be created - check_entry_fail $IP6_PEER UH + check_route_no_entry $IP6_PEER # Gateway is lo0 (RTF_GATEWAY) @@ -215,14 +185,14 @@ test_reject6() $DEBUG && rump.netstat -rn -f inet6 # Up, Gateway, Reject, Static - check_entry_flags fc00::/64 UGRS + check_route_flags fc00::/64 UGRS atf_check -s not-exit:0 -o ignore -e match:'Network is unreachable' \ rump.ping6 -n -X 1 -c 1 $IP6_PEER $DEBUG && rump.netstat -rn -f inet6 # Shouldn't be created - check_entry_fail $IP6_PEER UH + check_route_no_entry $IP6_PEER # Gateway is lo0 (RTF_HOST) @@ -235,7 +205,7 @@ test_reject6() $DEBUG && rump.netstat -rn -f inet6 # Up, Host, Reject, Static - check_entry_flags fc00:: UHRS + check_route_flags fc00:: UHRS atf_check -s not-exit:0 -o ignore -e match:'No route to host' \ rump.ping6 -n -X 1 -c 1 $IP6_PEER @@ -257,19 +227,11 @@ test_announce6() $DEBUG && rump.netstat -rn -f inet6 # Up, Gateway, Static, proxy - check_entry_flags fc00::/64 UGSp + check_route_flags fc00::/64 UGSp # TODO test its behavior } -cleanup() -{ - $DEBUG && /usr/bin/shmif_dumpbus -p - $BUS 2>/dev/null | \ - /usr/sbin/tcpdump -n -e -r - - env RUMP_SERVER=$SOCK_LOCAL rump.halt - env RUMP_SERVER=$SOCK_PEER rump.halt -} - add_test() { local name=$1 @@ -284,8 +246,10 @@ add_test() setup_local; \ setup_peer; \ test_${name}; \ + rump_server_destroy_ifaces; \ }; \ route_flags_${name}_cleanup() { \ + $DEBUG && dump; \ cleanup; \ }" atf_add_test_case "route_flags_${name}" diff --git a/contrib/netbsd-tests/net/route/t_route.sh b/contrib/netbsd-tests/net/route/t_route.sh index 37ede4ce..053f48f 100755 --- a/contrib/netbsd-tests/net/route/t_route.sh +++ b/contrib/netbsd-tests/net/route/t_route.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_route.sh,v 1.7 2016/08/10 23:00:39 roy Exp $ +# $NetBSD: t_route.sh,v 1.10 2016/12/21 02:46:08 ozaki-r Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -25,9 +25,6 @@ # POSSIBILITY OF SUCH DAMAGE. # -RUMP_LIBS="-lrumpdev -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif" -RUMP_LIBS_IPV6="$RUMP_LIBS -lrumpnet_netinet6" - # non_subnet_gateway SOCK_CLIENT=unix://commsock1 SOCK_GW=unix://commsock2 @@ -49,7 +46,7 @@ IP6DST=fc00:0:0:2::2 BUS_SRCGW=bus1 BUS_DSTGW=bus2 -DEBUG=false +DEBUG=${DEBUG:-false} TIMEOUT=1 PING_OPTS="-n -c 1 -w $TIMEOUT" @@ -64,13 +61,11 @@ route_non_subnet_gateway_head() route_non_subnet_gateway_body() { - atf_check -s exit:0 rump_server ${RUMP_LIBS} ${SOCK_CLIENT} - atf_check -s exit:0 rump_server ${RUMP_LIBS} ${SOCK_GW} + rump_server_start $SOCK_CLIENT + rump_server_start $SOCK_GW export RUMP_SERVER=${SOCK_GW} - - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS + rump_server_add_iface $SOCK_GW shmif0 $BUS atf_check -s exit:0 rump.ifconfig shmif0 192.168.0.1 atf_check -s exit:0 rump.ifconfig shmif0 up @@ -81,11 +76,10 @@ route_non_subnet_gateway_body() $DEBUG && rump.netstat -nr -f inet export RUMP_SERVER=${SOCK_CLIENT} - - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS + rump_server_add_iface $SOCK_CLIENT shmif0 $BUS atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.1/32 atf_check -s exit:0 rump.ifconfig shmif0 up + atf_check -s exit:0 rump.ifconfig -w 10 $DEBUG && rump.netstat -nr -f inet @@ -104,15 +98,14 @@ route_non_subnet_gateway_body() # Be reachable to the gateway atf_check -s exit:0 -o ignore rump.ping $PING_OPTS 192.168.0.1 - unset RUMP_SERVER + rump_server_destroy_ifaces } route_non_subnet_gateway_cleanup() { - $DEBUG && shmif_dumpbus -p - $BUS 2>/dev/null | tcpdump -n -e -r - - env RUMP_SERVER=$SOCK_CLIENT rump.halt - env RUMP_SERVER=$SOCK_GW rump.halt + $DEBUG && dump + cleanup } atf_test_case route_command_get cleanup @@ -140,8 +133,7 @@ setup_endpoint() local gw=${5} export RUMP_SERVER=${sock} - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${bus} + rump_server_add_iface $sock shmif0 $bus if [ $mode = "ipv6" ]; then atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${addr} atf_check -s exit:0 -o ignore rump.route add -inet6 default ${gw} @@ -150,6 +142,7 @@ setup_endpoint() atf_check -s exit:0 -o ignore rump.route add default ${gw} fi atf_check -s exit:0 rump.ifconfig shmif0 up + atf_check -s exit:0 rump.ifconfig -w 10 if $DEBUG; then rump.ifconfig shmif0 @@ -161,13 +154,10 @@ setup_forwarder() { mode=${1} - export RUMP_SERVER=$SOCKFWD - atf_check -s exit:0 rump.ifconfig shmif0 create - atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS_SRCGW - - atf_check -s exit:0 rump.ifconfig shmif1 create - atf_check -s exit:0 rump.ifconfig shmif1 linkstr $BUS_DSTGW + rump_server_add_iface $SOCKFWD shmif0 $BUS_SRCGW + rump_server_add_iface $SOCKFWD shmif1 $BUS_DSTGW + export RUMP_SERVER=$SOCKFWD if [ $mode = "ipv6" ]; then atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6SRCGW} atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6DSTGW} @@ -178,6 +168,7 @@ setup_forwarder() atf_check -s exit:0 rump.ifconfig shmif0 up atf_check -s exit:0 rump.ifconfig shmif1 up + atf_check -s exit:0 rump.ifconfig -w 10 if $DEBUG; then rump.netstat -nr @@ -204,9 +195,9 @@ setup_forwarding6() setup() { - atf_check -s exit:0 rump_server $RUMP_LIBS $SOCKSRC - atf_check -s exit:0 rump_server $RUMP_LIBS $SOCKFWD - atf_check -s exit:0 rump_server $RUMP_LIBS $SOCKDST + rump_server_start $SOCKSRC + rump_server_start $SOCKFWD + rump_server_start $SOCKDST setup_endpoint $SOCKSRC $IP4SRC $BUS_SRCGW ipv4 $IP4SRCGW setup_endpoint $SOCKDST $IP4DST $BUS_DSTGW ipv4 $IP4DSTGW @@ -216,9 +207,9 @@ setup() setup6() { - atf_check -s exit:0 rump_server $RUMP_LIBS_IPV6 $SOCKSRC - atf_check -s exit:0 rump_server $RUMP_LIBS_IPV6 $SOCKFWD - atf_check -s exit:0 rump_server $RUMP_LIBS_IPV6 $SOCKDST + rump_server_start $SOCKSRC netinet6 + rump_server_start $SOCKFWD netinet6 + rump_server_start $SOCKDST netinet6 setup_endpoint $SOCKSRC $IP6SRC $BUS_SRCGW ipv6 $IP6SRCGW setup_endpoint $SOCKDST $IP6DST $BUS_DSTGW ipv6 $IP6DSTGW @@ -380,6 +371,7 @@ route_command_get_body() setup setup_forwarding test_route_get + rump_server_destroy_ifaces } route_command_get6_body() @@ -388,36 +380,20 @@ route_command_get6_body() setup6 setup_forwarding6 test_route_get6 -} - -dump() -{ - - env RUMP_SERVER=$SOCKSRC rump.netstat -nr - env RUMP_SERVER=$SOCKFWD rump.netstat -nr - env RUMP_SERVER=$SOCKDST rump.netstat -nr - - shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r - - shmif_dumpbus -p - bus2 2>/dev/null| tcpdump -n -e -r - -} - -cleanup() -{ - - env RUMP_SERVER=$SOCKSRC rump.halt - env RUMP_SERVER=$SOCKFWD rump.halt - env RUMP_SERVER=$SOCKDST rump.halt + rump_server_destroy_ifaces } route_command_get_cleanup() { + $DEBUG && dump cleanup } route_command_get6_cleanup() { - dump + + $DEBUG && dump cleanup } diff --git a/contrib/netbsd-tests/rump/modautoload/t_modautoload.c b/contrib/netbsd-tests/rump/modautoload/t_modautoload.c index b73e52a..2c21a90 100644 --- a/contrib/netbsd-tests/rump/modautoload/t_modautoload.c +++ b/contrib/netbsd-tests/rump/modautoload/t_modautoload.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_modautoload.c,v 1.4 2015/12/27 08:21:44 pgoyette Exp $ */ +/* $NetBSD: t_modautoload.c,v 1.5 2016/09/14 03:19:11 ozaki-r Exp $ */ #include #include @@ -46,6 +46,7 @@ mountkernfs(void) atf_tc_fail_errno("mkdir /kern"); new_autoload = true; + old_len = sizeof(old_autoload); new_len = sizeof(new_autoload); error = sysctlbyname("kern.module.autoload", &old_autoload, &old_len, diff --git a/contrib/netbsd-tests/rump/rumpkern/t_lwproc.c b/contrib/netbsd-tests/rump/rumpkern/t_lwproc.c index d4eee3a..6e78d02 100644 --- a/contrib/netbsd-tests/rump/rumpkern/t_lwproc.c +++ b/contrib/netbsd-tests/rump/rumpkern/t_lwproc.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_lwproc.c,v 1.7 2015/01/21 15:19:01 pooka Exp $ */ +/* $NetBSD: t_lwproc.c,v 1.8 2017/01/10 22:36:29 christos Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -29,6 +29,7 @@ #include #include +#include #include #include diff --git a/contrib/netbsd-tests/sys/net/t_print.c b/contrib/netbsd-tests/sys/net/t_print.c index 0aaeb30..ff17895 100644 --- a/contrib/netbsd-tests/sys/net/t_print.c +++ b/contrib/netbsd-tests/sys/net/t_print.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_print.c,v 1.1 2014/12/02 19:48:21 christos Exp $ */ +/* $NetBSD: t_print.c,v 1.2 2016/08/27 11:30:49 christos Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_print.c,v 1.1 2014/12/02 19:48:21 christos Exp $"); +__RCSID("$NetBSD: t_print.c,v 1.2 2016/08/27 11:30:49 christos Exp $"); #include "net/dl_print.c" @@ -147,7 +147,10 @@ ATF_TC_BODY(sdl_print, tc) memcpy(&sdl.sdl_addr, &tst[i].ia, sizeof(sdl.sdl_addr)); sdl.sdl_index = (uint16_t)i; r = sdl_print(buf, l, &sdl); - e = snprintf(res, l, "[%s]:%zu", tst[i].str, i); + if (i == 3) + e = snprintf(res, l, "link#%zu", i); + else + e = snprintf(res, l, "[%s]:%zu", tst[i].str, i); ATF_REQUIRE_STREQ(buf, res); ATF_REQUIRE_EQ(r, e); } @@ -157,7 +160,10 @@ ATF_TC_BODY(sdl_print, tc) memcpy(&sdl.sdl_addr, &tst[i].ia, sizeof(sdl.sdl_addr)); sdl.sdl_index = (uint16_t)i; r = sdl_print(buf, l, &sdl); - e = snprintf(res, l, "[%s]:%zu", tst[i].str, i); + if (i == 3) + e = snprintf(res, l, "link#%zu", i); + else + e = snprintf(res, l, "[%s]:%zu", tst[i].str, i); ATF_REQUIRE_STREQ(buf, res); ATF_REQUIRE_EQ(r, e); } diff --git a/contrib/netbsd-tests/usr.bin/config/t_config.sh b/contrib/netbsd-tests/usr.bin/config/t_config.sh index 8a8079c..55af069 100755 --- a/contrib/netbsd-tests/usr.bin/config/t_config.sh +++ b/contrib/netbsd-tests/usr.bin/config/t_config.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_config.sh,v 1.7 2015/10/04 07:59:47 uebayasi Exp $ +# $NetBSD: t_config.sh,v 1.8 2016/08/27 12:08:14 christos Exp $ # # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,12 +25,32 @@ # POSSIBILITY OF SUCH DAMAGE. # +srcdir=.. +merge_backslash() +{ + sed ' +: again +/\\$/ { + N + s/\\\n// + t again +} +' "$1" +} run_and_check_prep() { local name="${1}"; shift - mkdir compile - supportdir="$(atf_get_srcdir)/support" + mkdir -p compile + srcdir="$(atf_get_srcdir)" + if [ ! -d "${srcdir}/support" ]; then + srcdir="$(dirname "${srcdir}")" + if [ ! -d "${srcdir}/support" ]; then + atf_fail "bad source directory ${srcdir}" + exit 1 + fi + fi + supportdir="${srcdir}/support" local config_str eval config_str=\$${name}_config_str @@ -38,7 +58,7 @@ run_and_check_prep() config="d_${name}" printf "$config_str" >"${config}" else - config="$(atf_get_srcdir)/d_${name}" + config="${srcdir}/d_${name}" fi } @@ -121,28 +141,28 @@ test_case deffs_redef fail "Checks that config doesn't allow a deffs to use" \ "the same name as a previous defflag/defparam" # Selecting an undefined option. -undefined_opt_config_str=' -include "../d_min" +undefined_opt_config_str=" +include \"${srcdir}/d_min\" options UNDEFINED -' +" test_case undefined_opt pass \ "Checks that config allows a selection for an undefined options" # Negating an undefined option. -no_undefined_opt_config_str=' -include "../d_min" +no_undefined_opt_config_str=" +include \"${srcdir}/d_min\" no options UNDEFINED -' +" no_undefined_opt_stderr='match:UNDEFINED' test_case no_undefined_opt warn \ "Checks that config allows a negation for an undefined options" # Attribute selection test_case select pass "Attribute selection" -select_config_str=' -include "../d_min" +select_config_str=" +include \"${srcdir}/d_min\" select c -' +" check_select() { local f=Makefile @@ -158,11 +178,11 @@ select_body() { # Attribute negation test_case no_select pass "Attribute negation" -no_select_config_str=' -include "../d_min" +no_select_config_str=" +include \"${srcdir}/d_min\" select c no select a -' +" check_no_select() { local f=Makefile @@ -181,10 +201,10 @@ no_select_body() { # Device instance test_case devi pass "Device instance" -devi_config_str=' -include "../d_min" +devi_config_str=" +include \"${srcdir}/d_min\" d0 at root -' +" check_devi() { local f=ioconf.c @@ -226,9 +246,7 @@ check_min_makefile() grep -q '^%' $f >tmp.template grep -q '^MACHINE=regress$' $f && - grep -q '^PARAM=-DMAXUSERS=4$' $f && - grep -q '^all: regress$' $f && - grep -q '^regress:' $f && + (merge_backslash $f | grep -q '^IDENT=[ ]*-DMAXUSERS="4"') && [ ! -s tmp.template ] && : } diff --git a/contrib/netbsd-tests/usr.bin/netpgpverify/t_netpgpverify.sh b/contrib/netbsd-tests/usr.bin/netpgpverify/t_netpgpverify.sh index 9c19116..2d532c0 100755 --- a/contrib/netbsd-tests/usr.bin/netpgpverify/t_netpgpverify.sh +++ b/contrib/netbsd-tests/usr.bin/netpgpverify/t_netpgpverify.sh @@ -1,6 +1,6 @@ #! /bin/sh -# $NetBSD: t_netpgpverify.sh,v 1.3 2016/06/01 06:39:11 agc Exp $ +# $NetBSD: t_netpgpverify.sh,v 1.4 2016/08/28 15:59:15 christos Exp $ # # Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -525,7 +525,7 @@ StZtC+VbuN66pfHwsAIAAw== EOF uudecode << EOF begin-base64 644 NetBSD-6.0_hashes.asc.gz -H4sICAAAAAACA05ldEJTRC02LjBfaGFzaGVzLmFzYwDUvduOXceVpX3deoq87B8o +H4sICLYIw1cCA05ldEJTRC02LjBfaGFzaGVzLmFzYwDUvduOXceVpX3deoq87B8o y3E+NNDA7yqrXQZKsmHZQN8V4igTRYkCSVWV++n7G4tMcu9kZnJlSgW4SYsmM3fG ihUz5pxjRMzDr37Fr3/86ne//+bmj7/74823v//dN1/99ubrr7799je/+0rf+9UX /9ze/PV/3Hz7z7+xX/Drz39dN/vVy5ev/uPFD9/dvHhz027Gq+9/fLnerpuXL968 @@ -6708,223 +6708,223 @@ pL+3CVk1P6YRa9KiMyiRJWfnUcDul1ZuoxYIExVsxJTRktenJljvSqENKgZEXQQW BeCV0wUcL/W2jQwurZdliEKl2Ol1HS0Xpw+yNnd9qx0rSprqJhxbsLFvfQAi0aZN pTRGqo9C9qYTP8xFN3tCiDKUTNeRnoJ2u51wDl1ddeJgE/FtR7seraSeOo4asdKK bxwm6/orfaEf8K9bixVNVftP13/91f5hVoH4dzDUKrcQQIuRU4qxndLiRl+02mk/ -Bh1fXF4EQ/TgfzV3bl1CFcmXf+dT9Oss12jmyfusNQ8IXpBWQW21fZmVVxtEEBRB -Pv3s3ymwq6CoOsXfB221Fak8eU5kRuzIjNi7Vu0jbRwtMMQ4a+7dRjdho1Re1isd -jn4IRwv/dXIzoZ9ZKHiqm4BLHEZZrFxTLDkprfdCiDD1piSMKCchDGZXsyvSn4kg -l1ahU6K3Ynyb+S6ZNo1KSiiGAF2hsHMklKdnizClGkjiYD5q9lwT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vxYf/P +90+fPPzllzvzw/FjdD9c/+fNx/Gbn6//+lX7/BMfvjS3W3ny4vdP7z/76scv71xL +dz+5+8v9B789/+H6jY++8f/qD5/867tvf/v1vbvP4/Wv8r3nn62n//zhy2dPzZ1b +X//7s0dPv8wf/+fn8u+b8fntj3+pz679+HG4ux798uv2y7f3y70Pknn69cOfPv3h +obt/68EHd776bdz843n/6ZPtm4fzwW/XP37+6fNfvvnm2b343c/Xn4YX9vtrX3zz +2U+Pv3/85fxo3rz/9ffX/xjLfPPi92d/rJ8+eXr39+/urC/y9+/d/c+PH7XH1/+1 +nt6+c/uLfHM9fHAvXQ9ffPjztce3bt2xjx494P6s3Pn27vXfb/vb7bv1zdMb9vH2 +5Na/f/rnJy/K7x8+/+TO/burfPX8n/67B5+37x+/mA+++/Wzm9f+Yz//9tvf/C/x +0U3/6ON79Yu7f3ypiPC5+f7bh09vvBf79a/uvffVk5+efGDufdp+/fDZD7999/TO +i7r9/uzzX839G9duf5TN3X/a+3cf3Lz707I37j364vtfPv3xt3+t35W6Xe/6bfnx +/V/e++3x7Yc/fPHj7Wc3Xnx076MH6+GjP8rPX975+doH//7i+bOP/p3vv7jR4s9P +zQfun59tN756+tuzm7d+/DLdjvX6oxg+/Ohbc7/Gr/8I9cUq929/9MX12+3FXD9+ +cu36XXvj0zuPXPz9h9/6oz8++LLceTpvP/sgmE8e/7g9efLRk5u/vLiRf/rsl/DA +3X04f/vpAz9/efrTN0/lc9972q+ZB1/f//zZjU9a/P73p4+/IF15+OT2rVuf3r31 +3Yzxu/7Tg3L/0xeP37t+3z76z40H9sObn3//6EF58Um7/ezu7XvX4h/3fnh+45O7 +5fP5xwfmgf3mvV8/uvZ/H33yXT/ZJLc+v3neFvn/qZKFEe79DQA= ==== EOF gunzip NetBSD-6.0_hashes.asc.gz @@ -6958,18 +6958,15 @@ YzFlNiBiZjcxIDg4NDUgNDE2YiA5NTIyIDc5ZGUgYjYxZSA0ODhlIGVlNzQgCgo= EOF uudecode << EOF beg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dGFpcmNyb29rcy5j +b20+CnVpZCAgICAgICAgICAgQWxpc3RhaXIgQ3Jvb2tzIDxhZ2NAcGtnc3JjLm9y +Zz4KdWlkICAgICAgICAgICBBbGlzdGFpciBDcm9va3MgPGFnY0BuZXRic2Qub3Jn +Pgp1aWQgICAgICAgICAgIEFsaXN0YWlyIENyb29rcyA8YWdjQG5ldGZsaXguY29t +PgoK ==== EOF uudecode << EOF @@ -6995,18 +6992,15 @@ aW5hcnkvdGV4dApiIGxlbmd0aApjIHN0cmluZwpMIG10aW1lCnRleHQK EOF uudecode << EOF begin-base64 644 expected21 -R29vZCBzaWduYXR1cmUgZm9yIFtzdGRpbl0gbWFkZSBTdW4gU2VwICA5IDE3OjQ0 -OjExIDIwMTIKc2lnbmF0dXJlICAyMDQ4L1JTQSAoRW5jcnlwdCBvciBTaWduKSAx -YjY4ZGNmY2MwNTk2ODIzIDIwMDQtMDEtMTIKZmluZ2VycHJpbnQ6ICBkNDE1IDlk -ZWIgMzM2ZCBlNGNjIGNkZmEgMDBjZCAxYjY4IGRjZmMgYzA1OSA2ODIzIAp1aWQg -ICAgICAgICAgICAgIEFsaXN0YWlyIENyb29rcyA8YWdjQGFsaXN0YWlyY3Jvb2tz -LmNvbT4KdWlkICAgICAgICAgICAgICBBbGlzdGFpciBDcm9va3MgPGFnY0Bwa2dz -cmMub3JnPgp1aWQgICAgICAgICAgICAgIEFsaXN0YWlyIENyb29rcyA8YWdjQG5l -dGJzZC5vcmc+CnVpZCAgICAgICAgICAgICAgQWxpc3RhaXIgQ3Jvb2tzIDxhZ2NA -bmV0ZmxpeC5jb20+CmVuY3J5cHRpb24gMjA0OC9SU0EgKEVuY3J5cHQgb3IgU2ln -bikgNzlkZWI2MWU0ODhlZWU3NCAyMDA0LTAxLTEyCmZpbmdlcnByaW50OiAgNTdj -MCBjMWU2IGJmNzEgODg0NSA0MTZiIDk1MjIgNzlkZSBiNjFlIDQ4OGUgZWU3NCAK -Cg== +R29vZCBzaWduYXR1cmU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YiBoYXNoIGFsZwpiIHB1YmtleSBhbGcKOGIga2V5aWQKCmxp +dGVyYWwgZGF0YSAodGFnIDExKQo9PT09PT09PT09PT09CmIgYmluYXJ5L3RleHQK +YiBsZW5ndGgKYyBzdHJpbmcKTCBtdGltZQp0ZXh0ClBST0c9cApTUkNTPXBhcnNl +LmMKV0FSTlM9NQpNS01BTj1ubwpDUFBGTEFHUys9LWcgLU8wCkxERkxBR1MrPS1n +IC1PMAoKLmluY2x1ZGUgPGJzZC5wcm9nLm1rPgoKdDogJHtQUk9HfQoJLi8ke1BS +T0d9IGdwZ3NpZ25lZC1hLmdwZwo= ==== EOF uudecode << EOF @@ -7207,13 +7194,12 @@ IG5ldHBncHZlcmlmeQo= ==== EOF atf_check -s eq:0 -o file:expected16 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg -c verify b.gpg - atf_check -s eq:0 -o file:2.expected -e empty b2e < 2.in - atf_check -s eq:0 -o file:expected18 -e empty env TZ=US/Pacific netpgpverify -c verify a.gpg - atf_check -s eq:0 -o file:expected19 -e empty env TZ=US/Pacific netpgpverify -c verify NetBSD-6.0_RC2_hashes.asc + atf_check -s eq:0 -o file:expected18 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg -c verify a.gpg +# atf_check -s eq:0 -o file:expected19 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg -c verify NetBSD-6.0_RC2_hashes.asc atf_check -s eq:0 -o file:expected20 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg -c cat jj.asc - atf_check -s eq:0 -o file:expected21 -e empty env TZ=US/Pacific netpgpverify < a.gpg + atf_check -s eq:0 -o file:expected21 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg < a.gpg atf_check -s eq:0 -o file:expected22 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg < jj.asc - atf_check -s eq:0 -o file:expected23 -e empty env TZ=US/Pacific netpgpverify < NetBSD-6.0_RC2_hashes.asc +# atf_check -s eq:0 -o file:expected23 -e empty env TZ=US/Pacific netpgpverify < NetBSD-6.0_RC2_hashes.asc atf_check -s eq:0 -o file:expected24 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg < b.gpg #atf_check -s eq:0 -o file:expected25 -e empty netpgpverify NetBSD-6.0_RC1_hashes.gpg #atf_check -s eq:0 -o file:expected26 -e empty netpgpverify < NetBSD-6.0_RC1_hashes.gpg @@ -7225,7 +7211,7 @@ EOF atf_check -s eq:0 -o file:expected32 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg b.gpg b.gpg b.gpg atf_check -s eq:0 -o file:expected33 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg -c cat b.gpg jj.asc b.gpg atf_check -s eq:0 -o file:expected34 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg det.sig - atf_check -s eq:0 -o file:expected35 -e empty env TZ=US/Pacific netpgpverify -c cat -k pubring.gpg det.sig + atf_check -s eq:0 -o file:expected35 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg -c cat det.sig #atf_check -s eq:0 -o file:expected46 -e empty netpgpverify -k problem-pubring.gpg NetBSD-6.0_hashes.asc } diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_union.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_union.c new file mode 100644 index 0000000..508bcc9 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_union.c @@ -0,0 +1,16 @@ +/* struct with only anonymous members */ + +struct foo { + union { + long loo; + double doo; + }; +}; + +int +main(void) { + + struct foo *f = 0; + printf("%p\n", &f[1]); + return 0; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_cast.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_cast.c new file mode 100644 index 0000000..31628b4 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_cast.c @@ -0,0 +1,18 @@ +/* union cast */ + +struct bar { + int a; + int b; +}; + +union foo { + struct bar *a; + int b; +}; + +void +foo(void) { + struct bar *a; + + ((union foo)a).a; +} diff --git a/lib/libc/tests/db/Makefile b/lib/libc/tests/db/Makefile index fe54d3b..c056384 100644 --- a/lib/libc/tests/db/Makefile +++ b/lib/libc/tests/db/Makefile @@ -7,12 +7,14 @@ PROGS+= h_lfsr FILESDIR= ${TESTSDIR} -FILES= README +FILES+= README NETBSD_ATF_TESTS_C+= db_hash_seq_test NETBSD_ATF_TESTS_SH+= db_test ATF_TESTS_SH_SED_db_test= -e 's,/bin/csh,/bin/cat,g' +CFLAGS+= -I${SRCTOP}/lib/libc/db/btree + .include "../Makefile.netbsd-tests" .include diff --git a/lib/libc/tests/gen/Makefile b/lib/libc/tests/gen/Makefile index 476b5b7..ac9f8e0 100644 --- a/lib/libc/tests/gen/Makefile +++ b/lib/libc/tests/gen/Makefile @@ -12,10 +12,20 @@ ATF_TESTS_C+= popen_test ATF_TESTS_C+= posix_spawn_test ATF_TESTS_C+= wordexp_test -# TODO: t_closefrom, t_cpuset, t_fmtcheck, t_randomid, t_sleep +# TODO: t_closefrom, t_cpuset, t_fmtcheck, t_randomid, # TODO: t_siginfo (fixes require further inspection) # TODO: t_sethostname_test (consistently screws up the hostname) +CFLAGS+= -DTEST_LONG_DOUBLE + +# Not sure why this isn't defined for all architectures, since most +# have long double. +.if ${MACHINE_CPUARCH} == "aarch64" || \ + ${MACHINE_CPUARCH} == "amd64" || \ + ${MACHINE_CPUARCH} == "i386" +CFLAGS+= -D__HAVE_LONG_DOUBLE +.endif + NETBSD_ATF_TESTS_C= alarm_test NETBSD_ATF_TESTS_C+= assert_test NETBSD_ATF_TESTS_C+= basedirname_test diff --git a/lib/libc/tests/stdlib/Makefile b/lib/libc/tests/stdlib/Makefile index af0341c..1548fac 100644 --- a/lib/libc/tests/stdlib/Makefile +++ b/lib/libc/tests/stdlib/Makefile @@ -10,6 +10,14 @@ ATF_TESTS_CXX+= cxa_thread_atexit_test ATF_TESTS_CXX+= cxa_thread_atexit_nothr_test .endif +# Not sure why this isn't defined for all architectures, since most +# have long double. +.if ${MACHINE_CPUARCH} == "aarch64" || \ + ${MACHINE_CPUARCH} == "amd64" || \ + ${MACHINE_CPUARCH} == "i386" +CFLAGS+= -D__HAVE_LONG_DOUBLE +.endif + # TODO: t_getenv_thread, t_mi_vector_hash, t_strtoi NETBSD_ATF_TESTS_C+= abs_test NETBSD_ATF_TESTS_C+= atoi_test diff --git a/lib/libc/tests/sys/Makefile b/lib/libc/tests/sys/Makefile index ed5eaa9..be2f4e7 100644 --- a/lib/libc/tests/sys/Makefile +++ b/lib/libc/tests/sys/Makefile @@ -59,6 +59,8 @@ NETBSD_ATF_TESTS_C+= ucontext_test NETBSD_ATF_TESTS_C+= umask_test NETBSD_ATF_TESTS_C+= unlink_test NETBSD_ATF_TESTS_C+= wait_test +NETBSD_ATF_TESTS_C+= wait_noproc_test +NETBSD_ATF_TESTS_C+= wait_noproc_wnohang_test NETBSD_ATF_TESTS_C+= write_test DPADD.getpid_test+= ${LIBPTHREAD} @@ -66,6 +68,8 @@ LDADD.getpid_test+= -lpthread DPADD.timer_create_test+= ${LIBRT} LDADD.timer_create_test+= -lrt +CSTD?= c99 + .include "../Makefile.netbsd-tests" SRCS.mlock_test+= mlock_helper.c diff --git a/lib/libthr/tests/Makefile b/lib/libthr/tests/Makefile index b0725dc..cd8f868 100644 --- a/lib/libthr/tests/Makefile +++ b/lib/libthr/tests/Makefile @@ -22,6 +22,7 @@ NETBSD_ATF_TESTS_C+= sigsuspend_test NETBSD_ATF_TESTS_C+= siglongjmp_test NETBSD_ATF_TESTS_C+= sleep_test NETBSD_ATF_TESTS_C+= swapcontext_test +NETBSD_ATF_TESTS_C+= timedmutex_test NETBSD_ATF_TESTS_SH= atexit_test NETBSD_ATF_TESTS_SH+= cancel_test diff --git a/lib/msun/tests/Makefile b/lib/msun/tests/Makefile index 9b4e9c7..318fc7b 100644 --- a/lib/msun/tests/Makefile +++ b/lib/msun/tests/Makefile @@ -16,12 +16,15 @@ NETBSD_ATF_TESTS_C+= asin_test NETBSD_ATF_TESTS_C+= atan_test NETBSD_ATF_TESTS_C+= cbrt_test NETBSD_ATF_TESTS_C+= ceil_test +NETBSD_ATF_TESTS_C+= casinh_test NETBSD_ATF_TESTS_C+= cos_test NETBSD_ATF_TESTS_C+= cosh_test NETBSD_ATF_TESTS_C+= erf_test NETBSD_ATF_TESTS_C+= exp_test NETBSD_ATF_TESTS_C+= fmod_test +NETBSD_ATF_TESTS_C+= fe_round_test NETBSD_ATF_TESTS_C+= infinity_test +NETBSD_ATF_TESTS_C+= ilogb_test NETBSD_ATF_TESTS_C+= ldexp_test NETBSD_ATF_TESTS_C+= log_test NETBSD_ATF_TESTS_C+= pow_test @@ -42,7 +45,7 @@ TAP_TESTS_C+= exponential_test TAP_TESTS_C+= fenv_test TAP_TESTS_C+= fma_test TAP_TESTS_C+= fmaxmin_test -TAP_TESTS_C+= ilogb_test +TAP_TESTS_C+= ilogb2_test TAP_TESTS_C+= invtrig_test TAP_TESTS_C+= invctrig_test TAP_TESTS_C+= logarithm_test @@ -68,6 +71,8 @@ DPADD+= ${LIBM} IGNORE_PRAGMA= +SRCS.ilogb2_test= ilogb_test.c + # Copied from lib/msun/Makefile .if ${MACHINE_CPUARCH} == "i386" ARCH_SUBDIR= i387 -- cgit v1.1 From 8d28fda3179b76e391004630320795f788da145e Mon Sep 17 00:00:00 2001 From: kib Date: Fri, 10 Feb 2017 14:38:28 +0000 Subject: MFC r290101 (by hselasky): Build fix for i386/XBOX and pc98/GENERIC. Reported by: ngie --- sys/i386/i386/pmap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index c383f34..8e51753 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -1257,8 +1257,10 @@ pmap_invalidate_cache_range(vm_offset_t sva, vm_offset_t eva, boolean_t force) sfence(); } else if ((cpu_feature & CPUID_CLFSH) != 0 && eva - sva < PMAP_CLFLUSH_THRESHOLD) { +#ifdef DEV_APIC if (pmap_kextract(sva) == lapic_paddr) return; +#endif /* * Writes are ordered by CLFLUSH on Intel CPUs. */ -- cgit v1.1 From 24a80a3173e1990c42b9f5db56d2736189decc2f Mon Sep 17 00:00:00 2001 From: emaste Date: Fri, 10 Feb 2017 15:02:56 +0000 Subject: MFC r308312: vidcontrol: improve error handling in vt(4) font loading PR: 209078 --- usr.sbin/vidcontrol/vidcontrol.c | 44 ++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/usr.sbin/vidcontrol/vidcontrol.c b/usr.sbin/vidcontrol/vidcontrol.c index e1981f3..5933dcd 100644 --- a/usr.sbin/vidcontrol/vidcontrol.c +++ b/usr.sbin/vidcontrol/vidcontrol.c @@ -393,11 +393,15 @@ load_vt4mappingtable(unsigned int nmappings, FILE *f) if (nmappings == 0) return (NULL); - t = malloc(sizeof *t * nmappings); + if ((t = malloc(sizeof *t * nmappings)) == NULL) { + warn("malloc"); + return (NULL); + } if (fread(t, sizeof *t * nmappings, 1, f) != 1) { - perror("mappings"); - exit(1); + warn("read mappings"); + free(t); + return (NULL); } for (i = 0; i < nmappings; i++) { @@ -422,7 +426,7 @@ load_default_vt4font(void) } } -static int +static void load_vt4font(FILE *f) { struct vt4font_header fh; @@ -431,13 +435,13 @@ load_vt4font(FILE *f) unsigned int i; if (fread(&fh, sizeof fh, 1, f) != 1) { - perror("file_header"); - return (1); + warn("read file_header"); + return; } if (memcmp(fh.magic, "VFNT0002", 8) != 0) { - fprintf(stderr, "Bad magic\n"); - return (1); + warnx("bad magic in font file\n"); + return; } for (i = 0; i < VFNT_MAPS; i++) @@ -447,21 +451,26 @@ load_vt4font(FILE *f) vfnt.height = fh.height; glyphsize = howmany(vfnt.width, 8) * vfnt.height * vfnt.glyph_count; - vfnt.glyphs = malloc(glyphsize); + if ((vfnt.glyphs = malloc(glyphsize)) == NULL) { + warn("malloc"); + return; + } if (fread(vfnt.glyphs, glyphsize, 1, f) != 1) { - perror("glyphs"); - return (1); + warn("read glyphs"); + free(vfnt.glyphs); + return; } for (i = 0; i < VFNT_MAPS; i++) vfnt.map[i] = load_vt4mappingtable(vfnt.map_count[i], f); - if (ioctl(STDIN_FILENO, PIO_VFONT, &vfnt) == -1) { - perror("PIO_VFONT"); - return (1); - } - return (0); + if (ioctl(STDIN_FILENO, PIO_VFONT, &vfnt) == -1) + warn("PIO_VFONT"); + + for (i = 0; i < VFNT_MAPS; i++) + free(vfnt.map[i]); + free(vfnt.glyphs); } /* @@ -511,8 +520,7 @@ load_font(const char *type, const char *filename) } if (vt4_mode) { - if(load_vt4font(fd)) - warn("failed to load font \"%s\"", filename); + load_vt4font(fd); fclose(fd); return; } -- cgit v1.1 From 58b22c1b2c60ef4d8f1b33b394a9b44e04507ca1 Mon Sep 17 00:00:00 2001 From: vangyzen Date: Fri, 10 Feb 2017 16:11:11 +0000 Subject: MFC r313401 Fix garbage IP addresses in UDP log_in_vain messages If multiple threads emit a UDP log_in_vain message concurrently, or indeed call inet_ntoa() for any other reason, the IP addresses could be garbage due to concurrent usage of a single string buffer inside inet_ntoa(). Use inet_ntoa_r() with two stack buffers instead. Relnotes: yes Sponsored by: Dell EMC --- sys/netinet/udp_usrreq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 79a2166..f43e567 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -647,13 +647,13 @@ udp_input(struct mbuf *m, int off) INPLOOKUP_RLOCKPCB, ifp, m); if (inp == NULL) { if (udp_log_in_vain) { - char buf[4*sizeof "123"]; + char src[INET_ADDRSTRLEN]; + char dst[INET_ADDRSTRLEN]; - strcpy(buf, inet_ntoa(ip->ip_dst)); log(LOG_INFO, "Connection attempt to UDP %s:%d from %s:%d\n", - buf, ntohs(uh->uh_dport), inet_ntoa(ip->ip_src), - ntohs(uh->uh_sport)); + inet_ntoa_r(ip->ip_dst, dst), ntohs(uh->uh_dport), + inet_ntoa_r(ip->ip_src, src), ntohs(uh->uh_sport)); } UDPSTAT_INC(udps_noport); if (m->m_flags & (M_BCAST | M_MCAST)) { -- cgit v1.1 From d7477941dbaca1a8f2916a367c2926e5fd74c7e6 Mon Sep 17 00:00:00 2001 From: mm Date: Sat, 11 Feb 2017 00:56:18 +0000 Subject: MFC r310866,310868,310870,311903,313074: Sync libarchive with vendor. MFC r310866: PR #771: Add NFSv4 ACL support to pax and restricted pax NFSv4 ACL information may now be stored to and restored from tar archives. ACL must be non-trivial and supported by the underlying filesystem, e.g. natively by ZFS or by UFS with the NFSv4 ACL enable flag set. MFC r310868: PR #843: Fix memory leak of struct archive_entry in cpio/cpio.c PR #851: Spelling fixes Fix two protoypes in manual page archive_read_disk.3 MFC r310870: Use __LA_DEPRECATED macro with functions deprecated in 379867e MFC r311903: #691: Support for SCHILY.xattr extended attributes #854: Spelling fixes Multiple fixes in ACL code: - prefer acl_set_fd_np() to acl_set_fd() - if acl_set_fd_np() fails, do no fallback to acl_set_file() - do not warn if trying to write ACLs to a filesystem without ACL support - fix id handling in archive_acl_(from_to)_text*() for NFSv4 ACLs MFC r313074: - support extracting NFSv4 ACLs from Solaris tar archives - bugfixes and optimizations in the ACL code - multiple fixes in the test suite - typo and other small bugfixes Security fixes: - cab reader: endless loop when parsing MSZIP signature (OSS-Fuzz 335) - LHA reader: heap-buffer-overflow in lha_read_file_header_1() (CVE-2017-5601) - LZ4 reader: null-pointer dereference in lz4_filter_read_legacy_stream() (OSS-Fuzz 453) - mtree reader: heap-buffer-overflow in detect_form() (OSS-Fuzz 421, 443) - WARC reader: heap-buffer-overflow in xstrpisotime() (OSS-Fuzz 382, 458) Memory leak fixes: - ACL support: free memory allocated by acl_get_qualifier() - disk writer: missing free in create_filesystem_object() - file reader: fd leak (Coverity 1016755) - gnutar writer: fix free in archive_write_gnutar_header() (Coverity 101675) - iso 9660 reader: missing free in parse_file_info() (partial Coverity 1016754) - program reader: missing free in __archive_read_program() - program writer: missing free in __archive_write_program_free() - xar reader: missing free in xar_cleanup() - xar reader: missing frees in expat_xmlattr_setup() (Coverity 1229979-1229981) - xar writer: missing free in file_free() - zip reader: missing free in zip_read_local_file_header() List of all libarchive issues at OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/list?can=1&q=libarchive Security: CVE-2017-5601 --- ObsoleteFiles.inc | 2 + contrib/libarchive/NEWS | 7 + contrib/libarchive/cpio/cpio.c | 1 + contrib/libarchive/libarchive/archive_acl.c | 1636 +++++++++++++++----- .../libarchive/libarchive/archive_acl_private.h | 22 +- contrib/libarchive/libarchive/archive_entry.c | 114 +- contrib/libarchive/libarchive/archive_entry.h | 63 +- contrib/libarchive/libarchive/archive_entry_acl.3 | 317 +++- .../libarchive/libarchive/archive_entry_locale.h | 10 +- .../libarchive/libarchive/archive_entry_strmode.c | 2 +- contrib/libarchive/libarchive/archive_match.c | 12 +- contrib/libarchive/libarchive/archive_platform.h | 19 +- contrib/libarchive/libarchive/archive_random.c | 2 +- contrib/libarchive/libarchive/archive_rb.c | 2 +- contrib/libarchive/libarchive/archive_read_disk.3 | 6 +- .../libarchive/archive_read_disk_entry_from_file.c | 734 ++++++++- .../libarchive/archive_read_disk_posix.c | 6 +- .../libarchive/archive_read_open_filename.c | 20 +- .../libarchive/archive_read_support_filter_lz4.c | 11 +- .../libarchive/archive_read_support_filter_lzop.c | 2 +- .../archive_read_support_filter_program.c | 2 + .../libarchive/archive_read_support_format_7zip.c | 10 +- .../libarchive/archive_read_support_format_cab.c | 2 + .../libarchive/archive_read_support_format_cpio.c | 3 +- .../archive_read_support_format_iso9660.c | 40 +- .../libarchive/archive_read_support_format_lha.c | 5 +- .../libarchive/archive_read_support_format_mtree.c | 8 +- .../libarchive/archive_read_support_format_rar.c | 2 +- .../libarchive/archive_read_support_format_tar.c | 162 +- .../libarchive/archive_read_support_format_warc.c | 6 +- .../libarchive/archive_read_support_format_xar.c | 6 +- .../libarchive/archive_read_support_format_zip.c | 16 +- contrib/libarchive/libarchive/archive_string.c | 26 +- contrib/libarchive/libarchive/archive_string.h | 4 + .../libarchive/archive_string_composition.h | 2 +- contrib/libarchive/libarchive/archive_write.c | 2 +- .../libarchive/archive_write_add_filter_program.c | 1 + .../libarchive/archive_write_add_filter_xz.c | 2 +- .../libarchive/libarchive/archive_write_disk_acl.c | 444 +++++- .../libarchive/archive_write_disk_posix.c | 62 +- contrib/libarchive/libarchive/archive_write_open.3 | 11 + .../libarchive/archive_write_set_format_7zip.c | 2 +- .../libarchive/archive_write_set_format_gnutar.c | 8 +- .../libarchive/archive_write_set_format_iso9660.c | 34 +- .../libarchive/archive_write_set_format_pax.c | 177 ++- .../libarchive/archive_write_set_format_warc.c | 2 +- .../libarchive/archive_write_set_format_xar.c | 15 +- .../libarchive/archive_write_set_format_zip.c | 10 +- contrib/libarchive/libarchive/libarchive-formats.5 | 4 +- contrib/libarchive/libarchive/tar.5 | 11 +- contrib/libarchive/libarchive/test/main.c | 134 ++ contrib/libarchive/libarchive/test/test.h | 43 + .../libarchive/test/test_acl_freebsd_nfs4.c | 547 ------- .../libarchive/test/test_acl_freebsd_posix1e.c | 418 ----- contrib/libarchive/libarchive/test/test_acl_nfs4.c | 126 +- contrib/libarchive/libarchive/test/test_acl_pax.c | 364 +++-- .../libarchive/libarchive/test/test_acl_pax.tar.uu | 117 -- .../libarchive/test/test_acl_pax_nfs4.tar.uu | 129 ++ .../libarchive/test/test_acl_pax_posix1e.tar.uu | 117 ++ .../libarchive/test/test_acl_platform_nfs4.c | 933 +++++++++++ .../libarchive/test/test_acl_platform_posix1e.c | 653 ++++++++ .../libarchive/libarchive/test/test_acl_posix1e.c | 144 +- contrib/libarchive/libarchive/test/test_acl_text.c | 462 ++++++ .../test/test_archive_read_add_passphrase.c | 2 +- .../libarchive/test/test_archive_string.c | 24 + .../libarchive/libarchive/test/test_compat_gtar.c | 2 + .../libarchive/test/test_compat_solaris_tar_acl.c | 297 +++- .../test/test_compat_solaris_tar_acl.tar.uu | 220 ++- .../libarchive/test/test_compat_star_acl.c | 321 ++++ .../test/test_compat_star_acl_nfs4.tar.uu | 231 +++ .../libarchive/test/test_compat_star_acl_posix1e.c | 215 --- .../libarchive/test/test_compat_uudecode.c | 2 +- contrib/libarchive/libarchive/test/test_fuzz.c | 4 + .../test/test_read_disk_directory_traversals.c | 12 +- .../libarchive/test/test_read_filter_lzop.c | 9 +- .../test/test_read_filter_lzop_multiple_parts.c | 8 +- .../libarchive/test/test_read_format_7zip.c | 2 +- .../libarchive/test/test_read_format_cpio_afio.c | 2 +- .../libarchive/test/test_read_format_isorr_bz2.c | 2 +- .../libarchive/test/test_read_format_zip.c | 5 + .../test/test_read_format_zip_comment_stored.c | 2 + .../test/test_read_format_zip_filename.c | 2 +- .../test/test_read_format_zip_mac_metadata.c | 2 + .../test/test_read_format_zip_malformed.c | 1 + .../libarchive/test/test_read_format_zip_nested.c | 2 + .../libarchive/test/test_read_format_zip_padded.c | 2 + .../libarchive/test/test_read_format_zip_sfx.c | 2 + ...t_read_format_zip_traditional_encryption_data.c | 4 +- .../test/test_read_format_zip_winzip_aes.c | 2 +- .../test/test_read_format_zip_winzip_aes_large.c | 2 +- .../libarchive/test/test_read_pax_schily_xattr.c | 70 + .../test/test_read_pax_schily_xattr.tar.uu | 231 +++ .../libarchive/libarchive/test/test_sparse_basic.c | 2 +- .../libarchive/test/test_write_disk_secure746.c | 3 + .../libarchive/test/test_write_filter_lz4.c | 2 + .../libarchive/test/test_write_filter_lzop.c | 6 +- .../libarchive/test/test_write_format_iso9660.c | 2 +- .../test/test_write_format_iso9660_zisofs.c | 2 +- .../libarchive/test/test_write_format_zip_large.c | 1 + .../libarchive/test/test_write_format_zip_zip64.c | 2 + contrib/libarchive/libarchive/xxhash.c | 5 +- .../libarchive/tar/test/test_option_uid_uname.c | 8 +- contrib/libarchive/tar/util.c | 1 + lib/libarchive/config_freebsd.h | 1 + lib/libarchive/tests/Makefile | 13 +- 105 files changed, 7277 insertions(+), 2705 deletions(-) delete mode 100644 contrib/libarchive/libarchive/test/test_acl_freebsd_nfs4.c delete mode 100644 contrib/libarchive/libarchive/test/test_acl_freebsd_posix1e.c delete mode 100644 contrib/libarchive/libarchive/test/test_acl_pax.tar.uu create mode 100644 contrib/libarchive/libarchive/test/test_acl_pax_nfs4.tar.uu create mode 100644 contrib/libarchive/libarchive/test/test_acl_pax_posix1e.tar.uu create mode 100644 contrib/libarchive/libarchive/test/test_acl_platform_nfs4.c create mode 100644 contrib/libarchive/libarchive/test/test_acl_platform_posix1e.c create mode 100644 contrib/libarchive/libarchive/test/test_acl_text.c create mode 100644 contrib/libarchive/libarchive/test/test_compat_star_acl.c create mode 100644 contrib/libarchive/libarchive/test/test_compat_star_acl_nfs4.tar.uu delete mode 100644 contrib/libarchive/libarchive/test/test_compat_star_acl_posix1e.c create mode 100644 contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.c create mode 100644 contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.tar.uu diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index 51b7ed2..cca3c71 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -38,6 +38,8 @@ # xargs -n1 | sort | uniq -d; # done +# 20170211: libarchive ACL pax test renamed to test_acl_pax_posix1e.tar.uu +OLD_FILES+=usr/tests/lib/libarchive/test_acl_pax.tar.uu # 20161229: Three files from gnop tests consolidated into one OLD_FILES+=usr/tests/sys/geom/class/nop/1_test OLD_FILES+=usr/tests/sys/geom/class/nop/2_test diff --git a/contrib/libarchive/NEWS b/contrib/libarchive/NEWS index 6f16b88..7b5c31f 100644 --- a/contrib/libarchive/NEWS +++ b/contrib/libarchive/NEWS @@ -1,3 +1,10 @@ +Jan 29, 2017: Limited NFSv4 ACL support for Mac OS (Darwin) + +Jan 10, 2017: POSIX.1e and NFSv4 ACL support for Solaris and derivates + +Dec 27, 2016: NFSv4 ACL read and write support for pax + Deprecated functions: archive_entry_acl_text(), archive_entry_acl_text_w() + Oct 26, 2016: Remove liblzmadec support Oct 23, 2016: libarchive 3.2.2 released diff --git a/contrib/libarchive/cpio/cpio.c b/contrib/libarchive/cpio/cpio.c index a7a747a..30c9ad3 100644 --- a/contrib/libarchive/cpio/cpio.c +++ b/contrib/libarchive/cpio/cpio.c @@ -703,6 +703,7 @@ file_to_archive(struct cpio *cpio, const char *srcpath) lafe_warnc(0, "%s", archive_error_string(cpio->archive_read_disk)); if (r <= ARCHIVE_FAILED) { + archive_entry_free(entry); cpio->return_value = 1; return (r); } diff --git a/contrib/libarchive/libarchive/archive_acl.c b/contrib/libarchive/libarchive/archive_acl.c index 3653d6f..1e9ddbb 100644 --- a/contrib/libarchive/libarchive/archive_acl.c +++ b/contrib/libarchive/libarchive/archive_acl.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2003-2010 Tim Kientzle + * Copyright (c) 2016 Martin Matuska * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -55,23 +56,31 @@ static struct archive_acl_entry *acl_new_entry(struct archive_acl *acl, static int archive_acl_add_entry_len_l(struct archive_acl *acl, int type, int permset, int tag, int id, const char *name, size_t len, struct archive_string_conv *sc); +static int archive_acl_text_want_type(struct archive_acl *acl, int flags); +static ssize_t archive_acl_text_len(struct archive_acl *acl, int want_type, + int flags, int wide, struct archive *a, + struct archive_string_conv *sc); static int isint_w(const wchar_t *start, const wchar_t *end, int *result); static int ismode_w(const wchar_t *start, const wchar_t *end, int *result); +static int is_nfs4_flags_w(const wchar_t *start, const wchar_t *end, + int *result); +static int is_nfs4_perms_w(const wchar_t *start, const wchar_t *end, + int *result); static void next_field_w(const wchar_t **wp, const wchar_t **start, const wchar_t **end, wchar_t *sep); -static int prefix_w(const wchar_t *start, const wchar_t *end, - const wchar_t *test); -static void append_entry_w(wchar_t **wp, const wchar_t *prefix, int tag, - const wchar_t *wname, int perm, int id); +static void append_entry_w(wchar_t **wp, const wchar_t *prefix, int type, + int tag, int flags, const wchar_t *wname, int perm, int id); static void append_id_w(wchar_t **wp, int id); static int isint(const char *start, const char *end, int *result); static int ismode(const char *start, const char *end, int *result); +static int is_nfs4_flags(const char *start, const char *end, + int *result); +static int is_nfs4_perms(const char *start, const char *end, + int *result); static void next_field(const char **p, const char **start, const char **end, char *sep); -static int prefix_c(const char *start, const char *end, - const char *test); -static void append_entry(char **p, const char *prefix, int tag, - const char *name, int perm, int id); +static void append_entry(char **p, const char *prefix, int type, + int tag, int flags, const char *name, int perm, int id); static void append_id(char **p, int id); void @@ -340,6 +349,15 @@ archive_acl_count(struct archive_acl *acl, int want_type) } /* + * Return a bitmask of stored ACL types in an ACL list + */ +int +archive_acl_types(struct archive_acl *acl) +{ + return (acl->acl_types); +} + +/* * Prepare for reading entries from the ACL data. Returns a count * of entries matching "want_type", or zero if there are no * non-extended ACL entries of that type. @@ -375,8 +393,8 @@ archive_acl_reset(struct archive_acl *acl, int want_type) * standard permissions and include them in the returned list. */ int -archive_acl_next(struct archive *a, struct archive_acl *acl, int want_type, int *type, - int *permset, int *tag, int *id, const char **name) +archive_acl_next(struct archive *a, struct archive_acl *acl, int want_type, + int *type, int *permset, int *tag, int *id, const char **name) { *name = NULL; *id = -1; @@ -441,130 +459,273 @@ archive_acl_next(struct archive *a, struct archive_acl *acl, int want_type, int } /* - * Generate a text version of the ACL. The flags parameter controls - * the style of the generated ACL. + * Determine what type of ACL do we want */ -const wchar_t * -archive_acl_text_w(struct archive *a, struct archive_acl *acl, int flags) +static int +archive_acl_text_want_type(struct archive_acl *acl, int flags) { - int count; - size_t length; - const wchar_t *wname; - const wchar_t *prefix; - wchar_t separator; - struct archive_acl_entry *ap; - int id, r; - wchar_t *wp; + int want_type; - if (acl->acl_text_w != NULL) { - free (acl->acl_text_w); - acl->acl_text_w = NULL; + /* Check if ACL is NFSv4 */ + if ((acl->acl_types & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) { + /* NFSv4 should never mix with POSIX.1e */ + if ((acl->acl_types & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) + return (0); + else + return (ARCHIVE_ENTRY_ACL_TYPE_NFS4); } - separator = L','; + /* Now deal with POSIX.1e ACLs */ + + want_type = 0; + if ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) + want_type |= ARCHIVE_ENTRY_ACL_TYPE_ACCESS; + if ((flags & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) + want_type |= ARCHIVE_ENTRY_ACL_TYPE_DEFAULT; + + /* By default we want both access and default ACLs */ + if (want_type == 0) + return (ARCHIVE_ENTRY_ACL_TYPE_POSIX1E); + + return (want_type); +} + +/* + * Calculate ACL text string length + */ +static ssize_t +archive_acl_text_len(struct archive_acl *acl, int want_type, int flags, + int wide, struct archive *a, struct archive_string_conv *sc) { + struct archive_acl_entry *ap; + const char *name; + const wchar_t *wname; + int count, idlen, tmp, r; + ssize_t length; + size_t len; + count = 0; length = 0; - ap = acl->acl_head; - while (ap != NULL) { - if ((ap->type & flags) != 0) { - count++; - if ((flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT) && - (ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)) - length += 8; /* "default:" */ - length += 5; /* tag name */ - length += 1; /* colon */ - r = archive_mstring_get_wcs(a, &ap->name, &wname); - if (r == 0 && wname != NULL) - length += wcslen(wname); - else if (r < 0 && errno == ENOMEM) - return (NULL); - else - length += sizeof(uid_t) * 3 + 1; - length ++; /* colon */ + for (ap = acl->acl_head; ap != NULL; ap = ap->next) { + if ((ap->type & want_type) == 0) + continue; + /* + * Filemode-mapping ACL entries are stored exclusively in + * ap->mode so they should not be in the list + */ + if ((ap->type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) + && (ap->tag == ARCHIVE_ENTRY_ACL_USER_OBJ + || ap->tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ + || ap->tag == ARCHIVE_ENTRY_ACL_OTHER)) + continue; + count++; + if ((want_type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0 + && (ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) + length += 8; /* "default:" */ + switch (ap->tag) { + case ARCHIVE_ENTRY_ACL_USER_OBJ: + if (want_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) { + length += 6; /* "owner@" */ + break; + } + /* FALLTHROUGH */ + case ARCHIVE_ENTRY_ACL_USER: + case ARCHIVE_ENTRY_ACL_MASK: + length += 4; /* "user", "mask" */ + break; + case ARCHIVE_ENTRY_ACL_GROUP_OBJ: + if (want_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) { + length += 6; /* "group@" */ + break; + } + /* FALLTHROUGH */ + case ARCHIVE_ENTRY_ACL_GROUP: + case ARCHIVE_ENTRY_ACL_OTHER: + length += 5; /* "group", "other" */ + break; + case ARCHIVE_ENTRY_ACL_EVERYONE: + length += 9; /* "everyone@" */ + break; + } + length += 1; /* colon after tag */ + if (ap->tag == ARCHIVE_ENTRY_ACL_USER || + ap->tag == ARCHIVE_ENTRY_ACL_GROUP) { + if (wide) { + r = archive_mstring_get_wcs(a, &ap->name, + &wname); + if (r == 0 && wname != NULL) + length += wcslen(wname); + else if (r < 0 && errno == ENOMEM) + return (0); + else + length += sizeof(uid_t) * 3 + 1; + } else { + r = archive_mstring_get_mbs_l(&ap->name, &name, + &len, sc); + if (r != 0) + return (0); + if (len > 0 && name != NULL) + length += len; + else + length += sizeof(uid_t) * 3 + 1; + } + length += 1; /* colon after user or group name */ + } else if (want_type != ARCHIVE_ENTRY_ACL_TYPE_NFS4) + length += 1; /* 2nd colon empty user,group or other */ + + if (((flags & ARCHIVE_ENTRY_ACL_STYLE_SOLARIS) != 0) + && ((want_type & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) + && (ap->tag == ARCHIVE_ENTRY_ACL_OTHER + || ap->tag == ARCHIVE_ENTRY_ACL_MASK)) { + /* Solaris has no colon after other: and mask: */ + length = length - 1; + } + + if (want_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) { + /* rwxpdDaARWcCos:fdinSFI:deny */ + length += 27; + if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_DENY) == 0) + length += 1; /* allow, alarm, audit */ + } else length += 3; /* rwx */ + + if ((ap->tag == ARCHIVE_ENTRY_ACL_USER || + ap->tag == ARCHIVE_ENTRY_ACL_GROUP) && + (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID) != 0) { length += 1; /* colon */ - length += max(sizeof(uid_t), sizeof(gid_t)) * 3 + 1; - length ++; /* newline */ + /* ID digit count */ + idlen = 1; + tmp = ap->id; + while (tmp > 9) { + tmp = tmp / 10; + idlen++; + } + length += idlen; } - ap = ap->next; + length ++; /* entry separator */ } - if (count > 0 && ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0)) { - length += 10; /* "user::rwx\n" */ - length += 11; /* "group::rwx\n" */ - length += 11; /* "other::rwx\n" */ - } + /* Add filemode-mapping access entries to the length */ + if ((want_type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) { + if ((flags & ARCHIVE_ENTRY_ACL_STYLE_SOLARIS) != 0) { + /* "user::rwx\ngroup::rwx\nother:rwx\n" */ + length += 31; + } else { + /* "user::rwx\ngroup::rwx\nother::rwx\n" */ + length += 32; + } + } else if (count == 0) + return (0); - if (count == 0) + /* The terminating character is included in count */ + return (length); +} + +/* + * Generate a wide text version of the ACL. The flags parameter controls + * the type and style of the generated ACL. + */ +wchar_t * +archive_acl_to_text_w(struct archive_acl *acl, ssize_t *text_len, int flags, + struct archive *a) +{ + int count; + ssize_t length; + size_t len; + const wchar_t *wname; + const wchar_t *prefix; + wchar_t separator; + struct archive_acl_entry *ap; + int id, r, want_type; + wchar_t *wp, *ws; + + want_type = archive_acl_text_want_type(acl, flags); + + /* Both NFSv4 and POSIX.1 types found */ + if (want_type == 0) + return (NULL); + + if (want_type == ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) + flags |= ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT; + + length = archive_acl_text_len(acl, want_type, flags, 1, a, NULL); + + if (length == 0) return (NULL); + if (flags & ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA) + separator = L','; + else + separator = L'\n'; + /* Now, allocate the string and actually populate it. */ - wp = acl->acl_text_w = (wchar_t *)malloc(length * sizeof(wchar_t)); - if (wp == NULL) + wp = ws = (wchar_t *)malloc(length * sizeof(wchar_t)); + if (wp == NULL) { + if (errno == ENOMEM) + __archive_errx(1, "No memory"); return (NULL); + } count = 0; - if ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) { - append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_USER_OBJ, NULL, + + if ((want_type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) { + append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, + ARCHIVE_ENTRY_ACL_USER_OBJ, flags, NULL, acl->mode & 0700, -1); - *wp++ = ','; - append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_GROUP_OBJ, NULL, + *wp++ = separator; + append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, flags, NULL, acl->mode & 0070, -1); - *wp++ = ','; - append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_OTHER, NULL, + *wp++ = separator; + append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, + ARCHIVE_ENTRY_ACL_OTHER, flags, NULL, acl->mode & 0007, -1); count += 3; - - ap = acl->acl_head; - while (ap != NULL) { - if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) { - r = archive_mstring_get_wcs(a, &ap->name, &wname); - if (r == 0) { - *wp++ = separator; - if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID) - id = ap->id; - else - id = -1; - append_entry_w(&wp, NULL, ap->tag, wname, - ap->permset, id); - count++; - } else if (r < 0 && errno == ENOMEM) - return (NULL); - } - ap = ap->next; - } } - - if ((flags & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) { - if (flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT) + for (ap = acl->acl_head; ap != NULL; ap = ap->next) { + if ((ap->type & want_type) == 0) + continue; + /* + * Filemode-mapping ACL entries are stored exclusively in + * ap->mode so they should not be in the list + */ + if ((ap->type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) + && (ap->tag == ARCHIVE_ENTRY_ACL_USER_OBJ + || ap->tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ + || ap->tag == ARCHIVE_ENTRY_ACL_OTHER)) + continue; + if (ap->type == ARCHIVE_ENTRY_ACL_TYPE_DEFAULT && + (flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT) != 0) prefix = L"default:"; else prefix = NULL; - ap = acl->acl_head; - count = 0; - while (ap != NULL) { - if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) { - r = archive_mstring_get_wcs(a, &ap->name, &wname); - if (r == 0) { - if (count > 0) - *wp++ = separator; - if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID) - id = ap->id; - else - id = -1; - append_entry_w(&wp, prefix, ap->tag, - wname, ap->permset, id); - count ++; - } else if (r < 0 && errno == ENOMEM) - return (NULL); - } - ap = ap->next; - } + r = archive_mstring_get_wcs(a, &ap->name, &wname); + if (r == 0) { + if (count > 0) + *wp++ = separator; + if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID) + id = ap->id; + else + id = -1; + append_entry_w(&wp, prefix, ap->type, ap->tag, flags, + wname, ap->permset, id); + count++; + } else if (r < 0 && errno == ENOMEM) + return (NULL); } - return (acl->acl_text_w); -} + /* Add terminating character */ + *wp++ = L'\0'; + + len = wcslen(ws); + if ((ssize_t)len > (length - 1)) + __archive_errx(1, "Buffer overrun"); + + if (text_len != NULL) + *text_len = len; + + return (ws); +} static void append_id_w(wchar_t **wp, int id) @@ -577,8 +738,8 @@ append_id_w(wchar_t **wp, int id) } static void -append_entry_w(wchar_t **wp, const wchar_t *prefix, int tag, - const wchar_t *wname, int perm, int id) +append_entry_w(wchar_t **wp, const wchar_t *prefix, int type, + int tag, int flags, const wchar_t *wname, int perm, int id) { if (prefix != NULL) { wcscpy(*wp, prefix); @@ -588,6 +749,10 @@ append_entry_w(wchar_t **wp, const wchar_t *prefix, int tag, case ARCHIVE_ENTRY_ACL_USER_OBJ: wname = NULL; id = -1; + if ((type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) { + wcscpy(*wp, L"owner@"); + break; + } /* FALLTHROUGH */ case ARCHIVE_ENTRY_ACL_USER: wcscpy(*wp, L"user"); @@ -595,6 +760,10 @@ append_entry_w(wchar_t **wp, const wchar_t *prefix, int tag, case ARCHIVE_ENTRY_ACL_GROUP_OBJ: wname = NULL; id = -1; + if ((type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) { + wcscpy(*wp, L"group@"); + break; + } /* FALLTHROUGH */ case ARCHIVE_ENTRY_ACL_GROUP: wcscpy(*wp, L"group"); @@ -609,154 +778,210 @@ append_entry_w(wchar_t **wp, const wchar_t *prefix, int tag, wname = NULL; id = -1; break; + case ARCHIVE_ENTRY_ACL_EVERYONE: + wcscpy(*wp, L"everyone@"); + wname = NULL; + id = -1; + break; } *wp += wcslen(*wp); *(*wp)++ = L':'; - if (wname != NULL) { - wcscpy(*wp, wname); + if (((type & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) || + tag == ARCHIVE_ENTRY_ACL_USER || + tag == ARCHIVE_ENTRY_ACL_GROUP) { + if (wname != NULL) { + wcscpy(*wp, wname); + *wp += wcslen(*wp); + } else if (tag == ARCHIVE_ENTRY_ACL_USER + || tag == ARCHIVE_ENTRY_ACL_GROUP) { + append_id_w(wp, id); + if ((type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) == 0) + id = -1; + } + /* Solaris style has no second colon after other and mask */ + if (((flags & ARCHIVE_ENTRY_ACL_STYLE_SOLARIS) == 0) + || (tag != ARCHIVE_ENTRY_ACL_OTHER + && tag != ARCHIVE_ENTRY_ACL_MASK)) + *(*wp)++ = L':'; + } + if ((type & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) { + /* POSIX.1e ACL perms */ + *(*wp)++ = (perm & 0444) ? L'r' : L'-'; + *(*wp)++ = (perm & 0222) ? L'w' : L'-'; + *(*wp)++ = (perm & 0111) ? L'x' : L'-'; + } else { + /* NFS4 ACL perms */ + *(*wp)++ = (perm & (ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_LIST_DIRECTORY)) ? L'r' : L'-'; + *(*wp)++ = (perm & (ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_ADD_FILE)) ? L'w' : L'-'; + *(*wp)++ = (perm & ARCHIVE_ENTRY_ACL_EXECUTE) ? L'x' : L'-'; + *(*wp)++ = (perm & (ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY)) ? L'p' : L'-'; + *(*wp)++ = (perm & ARCHIVE_ENTRY_ACL_DELETE) ? L'd' : L'-'; + *(*wp)++ = (perm & + ARCHIVE_ENTRY_ACL_DELETE_CHILD) ? L'D' : L'-'; + *(*wp)++ = (perm & + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES) ? L'a' : L'-'; + *(*wp)++ = (perm & + ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES) ? L'A' : L'-'; + *(*wp)++ = (perm & + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS) ? L'R' : L'-'; + *(*wp)++ = (perm & + ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS) ? L'W' : L'-'; + *(*wp)++ = (perm & ARCHIVE_ENTRY_ACL_READ_ACL) ? L'c' : L'-'; + *(*wp)++ = (perm & ARCHIVE_ENTRY_ACL_WRITE_ACL) ? L'C' : L'-'; + *(*wp)++ = (perm & + ARCHIVE_ENTRY_ACL_WRITE_OWNER) ? L'o' : L'-'; + *(*wp)++ = (perm & + ARCHIVE_ENTRY_ACL_SYNCHRONIZE) ? L's' : L'-'; + *(*wp)++ = L':'; + *(*wp)++ = (perm & + ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT) ? L'f' : L'-'; + *(*wp)++ = (perm & + ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT) ? L'd' : L'-'; + *(*wp)++ = (perm & + ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY) ? L'i' : L'-'; + *(*wp)++ = (perm & + ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT) ? L'n' : L'-'; + *(*wp)++ = (perm & + ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS) ? L'S' : L'-'; + *(*wp)++ = (perm & + ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS) ? L'F' : L'-'; + *(*wp)++ = (perm & + ARCHIVE_ENTRY_ACL_ENTRY_INHERITED) ? L'I' : L'-'; + *(*wp)++ = L':'; + switch (type) { + case ARCHIVE_ENTRY_ACL_TYPE_ALLOW: + wcscpy(*wp, L"allow"); + break; + case ARCHIVE_ENTRY_ACL_TYPE_DENY: + wcscpy(*wp, L"deny"); + break; + case ARCHIVE_ENTRY_ACL_TYPE_AUDIT: + wcscpy(*wp, L"audit"); + break; + case ARCHIVE_ENTRY_ACL_TYPE_ALARM: + wcscpy(*wp, L"alarm"); + break; + default: + break; + } *wp += wcslen(*wp); - } else if (tag == ARCHIVE_ENTRY_ACL_USER - || tag == ARCHIVE_ENTRY_ACL_GROUP) { - append_id_w(wp, id); - id = -1; } - *(*wp)++ = L':'; - *(*wp)++ = (perm & 0444) ? L'r' : L'-'; - *(*wp)++ = (perm & 0222) ? L'w' : L'-'; - *(*wp)++ = (perm & 0111) ? L'x' : L'-'; if (id != -1) { *(*wp)++ = L':'; append_id_w(wp, id); } - **wp = L'\0'; } -int -archive_acl_text_l(struct archive_acl *acl, int flags, - const char **acl_text, size_t *acl_text_len, +/* + * Generate a text version of the ACL. The flags parameter controls + * the type and style of the generated ACL. + */ +char * +archive_acl_to_text_l(struct archive_acl *acl, ssize_t *text_len, int flags, struct archive_string_conv *sc) { int count; - size_t length; + ssize_t length; + size_t len; const char *name; const char *prefix; char separator; struct archive_acl_entry *ap; - size_t len; - int id, r; - char *p; + int id, r, want_type; + char *p, *s; - if (acl->acl_text != NULL) { - free (acl->acl_text); - acl->acl_text = NULL; - } + want_type = archive_acl_text_want_type(acl, flags); - *acl_text = NULL; - if (acl_text_len != NULL) - *acl_text_len = 0; - separator = ','; - count = 0; - length = 0; - ap = acl->acl_head; - while (ap != NULL) { - if ((ap->type & flags) != 0) { - count++; - if ((flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT) && - (ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)) - length += 8; /* "default:" */ - length += 5; /* tag name */ - length += 1; /* colon */ - r = archive_mstring_get_mbs_l( - &ap->name, &name, &len, sc); - if (r != 0) - return (-1); - if (len > 0 && name != NULL) - length += len; - else - length += sizeof(uid_t) * 3 + 1; - length ++; /* colon */ - length += 3; /* rwx */ - length += 1; /* colon */ - length += max(sizeof(uid_t), sizeof(gid_t)) * 3 + 1; - length ++; /* newline */ - } - ap = ap->next; - } + /* Both NFSv4 and POSIX.1 types found */ + if (want_type == 0) + return (NULL); - if (count > 0 && ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0)) { - length += 10; /* "user::rwx\n" */ - length += 11; /* "group::rwx\n" */ - length += 11; /* "other::rwx\n" */ - } + if (want_type == ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) + flags |= ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT; - if (count == 0) - return (0); + length = archive_acl_text_len(acl, want_type, flags, 0, NULL, sc); + + if (length == 0) + return (NULL); + + if (flags & ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA) + separator = ','; + else + separator = '\n'; /* Now, allocate the string and actually populate it. */ - p = acl->acl_text = (char *)malloc(length); - if (p == NULL) - return (-1); + p = s = (char *)malloc(length * sizeof(char)); + if (p == NULL) { + if (errno == ENOMEM) + __archive_errx(1, "No memory"); + return (NULL); + } count = 0; - if ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) { - append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_USER_OBJ, NULL, + + if ((want_type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) { + append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, + ARCHIVE_ENTRY_ACL_USER_OBJ, flags, NULL, acl->mode & 0700, -1); - *p++ = ','; - append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_GROUP_OBJ, NULL, + *p++ = separator; + append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, flags, NULL, acl->mode & 0070, -1); - *p++ = ','; - append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_OTHER, NULL, + *p++ = separator; + append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, + ARCHIVE_ENTRY_ACL_OTHER, flags, NULL, acl->mode & 0007, -1); count += 3; - - for (ap = acl->acl_head; ap != NULL; ap = ap->next) { - if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) == 0) - continue; - r = archive_mstring_get_mbs_l( - &ap->name, &name, &len, sc); - if (r != 0) - return (-1); - *p++ = separator; - if (name == NULL || (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)) { - id = ap->id; - } else { - id = -1; - } - append_entry(&p, NULL, ap->tag, name, - ap->permset, id); - count++; - } } - - if ((flags & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) { - if (flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT) + for (ap = acl->acl_head; ap != NULL; ap = ap->next) { + if ((ap->type & want_type) == 0) + continue; + /* + * Filemode-mapping ACL entries are stored exclusively in + * ap->mode so they should not be in the list + */ + if ((ap->type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) + && (ap->tag == ARCHIVE_ENTRY_ACL_USER_OBJ + || ap->tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ + || ap->tag == ARCHIVE_ENTRY_ACL_OTHER)) + continue; + if (ap->type == ARCHIVE_ENTRY_ACL_TYPE_DEFAULT && + (flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT) != 0) prefix = "default:"; else prefix = NULL; - count = 0; - for (ap = acl->acl_head; ap != NULL; ap = ap->next) { - if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) == 0) - continue; - r = archive_mstring_get_mbs_l( - &ap->name, &name, &len, sc); - if (r != 0) - return (-1); - if (count > 0) - *p++ = separator; - if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID) - id = ap->id; - else - id = -1; - append_entry(&p, prefix, ap->tag, - name, ap->permset, id); - count ++; + r = archive_mstring_get_mbs_l( + &ap->name, &name, &len, sc); + if (r != 0) + return (NULL); + if (count > 0) + *p++ = separator; + if (name == NULL || + (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)) { + id = ap->id; + } else { + id = -1; } + append_entry(&p, prefix, ap->type, ap->tag, flags, name, + ap->permset, id); + count++; } - *acl_text = acl->acl_text; - if (acl_text_len != NULL) - *acl_text_len = strlen(acl->acl_text); - return (0); + /* Add terminating character */ + *p++ = '\0'; + + len = strlen(s); + + if ((ssize_t)len > (length - 1)) + __archive_errx(1, "Buffer overrun"); + + if (text_len != NULL) + *text_len = len; + + return (s); } static void @@ -770,8 +995,8 @@ append_id(char **p, int id) } static void -append_entry(char **p, const char *prefix, int tag, - const char *name, int perm, int id) +append_entry(char **p, const char *prefix, int type, + int tag, int flags, const char *name, int perm, int id) { if (prefix != NULL) { strcpy(*p, prefix); @@ -781,6 +1006,10 @@ append_entry(char **p, const char *prefix, int tag, case ARCHIVE_ENTRY_ACL_USER_OBJ: name = NULL; id = -1; + if ((type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) { + strcpy(*p, "owner@"); + break; + } /* FALLTHROUGH */ case ARCHIVE_ENTRY_ACL_USER: strcpy(*p, "user"); @@ -788,6 +1017,10 @@ append_entry(char **p, const char *prefix, int tag, case ARCHIVE_ENTRY_ACL_GROUP_OBJ: name = NULL; id = -1; + if ((type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) { + strcpy(*p, "group@"); + break; + } /* FALLTHROUGH */ case ARCHIVE_ENTRY_ACL_GROUP: strcpy(*p, "group"); @@ -802,48 +1035,147 @@ append_entry(char **p, const char *prefix, int tag, name = NULL; id = -1; break; + case ARCHIVE_ENTRY_ACL_EVERYONE: + strcpy(*p, "everyone@"); + name = NULL; + id = -1; + break; } *p += strlen(*p); *(*p)++ = ':'; - if (name != NULL) { - strcpy(*p, name); + if (((type & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) || + tag == ARCHIVE_ENTRY_ACL_USER || + tag == ARCHIVE_ENTRY_ACL_GROUP) { + if (name != NULL) { + strcpy(*p, name); + *p += strlen(*p); + } else if (tag == ARCHIVE_ENTRY_ACL_USER + || tag == ARCHIVE_ENTRY_ACL_GROUP) { + append_id(p, id); + if ((type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) == 0) + id = -1; + } + /* Solaris style has no second colon after other and mask */ + if (((flags & ARCHIVE_ENTRY_ACL_STYLE_SOLARIS) == 0) + || (tag != ARCHIVE_ENTRY_ACL_OTHER + && tag != ARCHIVE_ENTRY_ACL_MASK)) + *(*p)++ = ':'; + } + if ((type & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) { + /* POSIX.1e ACL perms */ + *(*p)++ = (perm & 0444) ? 'r' : '-'; + *(*p)++ = (perm & 0222) ? 'w' : '-'; + *(*p)++ = (perm & 0111) ? 'x' : '-'; + } else { + /* NFS4 ACL perms */ + *(*p)++ = (perm & (ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_LIST_DIRECTORY)) ? 'r' : '-'; + *(*p)++ = (perm & (ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_ADD_FILE)) ? 'w' : '-'; + *(*p)++ = (perm & (ARCHIVE_ENTRY_ACL_EXECUTE)) ? 'x' : '-'; + *(*p)++ = (perm & (ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY)) ? 'p' : '-'; + *(*p)++ = (perm & ARCHIVE_ENTRY_ACL_DELETE) ? 'd' : '-'; + *(*p)++ = (perm & ARCHIVE_ENTRY_ACL_DELETE_CHILD) ? 'D' : '-'; + *(*p)++ = (perm & + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES) ? 'a' : '-'; + *(*p)++ = (perm & + ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES) ? 'A' : '-'; + *(*p)++ = (perm & + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS) ? 'R' : '-'; + *(*p)++ = (perm & + ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS) ? 'W' : '-'; + *(*p)++ = (perm & + ARCHIVE_ENTRY_ACL_READ_ACL) ? 'c' : '-'; + *(*p)++ = (perm & + ARCHIVE_ENTRY_ACL_WRITE_ACL) ? 'C' : '-'; + *(*p)++ = (perm & + ARCHIVE_ENTRY_ACL_WRITE_OWNER) ? 'o' : '-'; + *(*p)++ = (perm & + ARCHIVE_ENTRY_ACL_SYNCHRONIZE) ? 's' : '-'; + *(*p)++ = ':'; + *(*p)++ = (perm & + ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT) ? 'f' : '-'; + *(*p)++ = (perm & + ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT) ? 'd' : '-'; + *(*p)++ = (perm & + ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY) ? 'i' : '-'; + *(*p)++ = (perm & + ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT) ? 'n' : '-'; + *(*p)++ = (perm & + ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS) ? 'S' : '-'; + *(*p)++ = (perm & + ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS) ? 'F' : '-'; + *(*p)++ = (perm & + ARCHIVE_ENTRY_ACL_ENTRY_INHERITED) ? 'I' : '-'; + *(*p)++ = ':'; + switch (type) { + case ARCHIVE_ENTRY_ACL_TYPE_ALLOW: + strcpy(*p, "allow"); + break; + case ARCHIVE_ENTRY_ACL_TYPE_DENY: + strcpy(*p, "deny"); + break; + case ARCHIVE_ENTRY_ACL_TYPE_AUDIT: + strcpy(*p, "audit"); + break; + case ARCHIVE_ENTRY_ACL_TYPE_ALARM: + strcpy(*p, "alarm"); + break; + } *p += strlen(*p); - } else if (tag == ARCHIVE_ENTRY_ACL_USER - || tag == ARCHIVE_ENTRY_ACL_GROUP) { - append_id(p, id); - id = -1; } - *(*p)++ = ':'; - *(*p)++ = (perm & 0444) ? 'r' : '-'; - *(*p)++ = (perm & 0222) ? 'w' : '-'; - *(*p)++ = (perm & 0111) ? 'x' : '-'; if (id != -1) { *(*p)++ = ':'; append_id(p, id); } - **p = '\0'; } /* - * Parse a textual ACL. This automatically recognizes and supports - * extensions described above. The 'type' argument is used to - * indicate the type that should be used for any entries not - * explicitly marked as "default:". + * Parse a wide ACL text string. + * + * The want_type argument may be one of the following: + * ARCHIVE_ENTRY_ACL_TYPE_ACCESS - text is a POSIX.1e ACL of type ACCESS + * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - text is a POSIX.1e ACL of type DEFAULT + * ARCHIVE_ENTRY_ACL_TYPE_NFS4 - text is as a NFSv4 ACL + * + * POSIX.1e ACL entries prefixed with "default:" are treated as + * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT unless type is ARCHIVE_ENTRY_ACL_TYPE_NFS4 */ int -archive_acl_parse_w(struct archive_acl *acl, - const wchar_t *text, int default_type) +archive_acl_from_text_w(struct archive_acl *acl, const wchar_t *text, + int want_type) { struct { const wchar_t *start; const wchar_t *end; - } field[4], name; + } field[6], name; - int fields, n; - int type, tag, permset, id; + const wchar_t *s, *st; + + int numfields, fields, n, r, sol, ret; + int type, types, tag, permset, id; + size_t len; wchar_t sep; - while (text != NULL && *text != L'\0') { + ret = ARCHIVE_OK; + types = 0; + + switch (want_type) { + case ARCHIVE_ENTRY_ACL_TYPE_POSIX1E: + want_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS; + case ARCHIVE_ENTRY_ACL_TYPE_ACCESS: + case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT: + numfields = 5; + break; + case ARCHIVE_ENTRY_ACL_TYPE_NFS4: + numfields = 6; + break; + default: + return (ARCHIVE_FATAL); + } + + while (text != NULL && *text != L'\0') { /* * Parse the fields out of the next entry, * advance 'text' to start of next entry. @@ -852,7 +1184,7 @@ archive_acl_parse_w(struct archive_acl *acl, do { const wchar_t *start, *end; next_field_w(&text, &start, &end, &sep); - if (fields < 4) { + if (fields < numfields) { field[fields].start = start; field[fields].end = end; } @@ -860,78 +1192,210 @@ archive_acl_parse_w(struct archive_acl *acl, } while (sep == L':'); /* Set remaining fields to blank. */ - for (n = fields; n < 4; ++n) + for (n = fields; n < numfields; ++n) field[n].start = field[n].end = NULL; - /* Check for a numeric ID in field 1 or 3. */ - id = -1; - isint_w(field[1].start, field[1].end, &id); - /* Field 3 is optional. */ - if (id == -1 && fields > 3) - isint_w(field[3].start, field[3].end, &id); - - /* - * Solaris extension: "defaultuser::rwx" is the - * default ACL corresponding to "user::rwx", etc. - */ - if (field[0].end - field[0].start > 7 - && wmemcmp(field[0].start, L"default", 7) == 0) { - type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT; - field[0].start += 7; - } else - type = default_type; + if (field[0].start != NULL && *(field[0].start) == L'#') { + /* Comment, skip entry */ + continue; + } + n = 0; + sol = 0; + id = -1; + permset = 0; name.start = name.end = NULL; - if (prefix_w(field[0].start, field[0].end, L"user")) { - if (!ismode_w(field[2].start, field[2].end, &permset)) - return (ARCHIVE_WARN); - if (id != -1 || field[1].start < field[1].end) { - tag = ARCHIVE_ENTRY_ACL_USER; - name = field[1]; + + if (want_type != ARCHIVE_ENTRY_ACL_TYPE_NFS4) { + /* POSIX.1e ACLs */ + /* + * Default keyword "default:user::rwx" + * if found, we have one more field + * + * We also support old Solaris extension: + * "defaultuser::rwx" is the default ACL corresponding + * to "user::rwx", etc. valid only for first field + */ + s = field[0].start; + len = field[0].end - field[0].start; + if (*s == L'd' && (len == 1 || (len >= 7 + && wmemcmp((s + 1), L"efault", 6) == 0))) { + type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT; + if (len > 7) + field[0].start += 7; + else + n = 1; } else - tag = ARCHIVE_ENTRY_ACL_USER_OBJ; - } else if (prefix_w(field[0].start, field[0].end, L"group")) { - if (!ismode_w(field[2].start, field[2].end, &permset)) - return (ARCHIVE_WARN); - if (id != -1 || field[1].start < field[1].end) { - tag = ARCHIVE_ENTRY_ACL_GROUP; + type = want_type; + + /* Check for a numeric ID in field n+1 or n+3. */ + isint_w(field[n + 1].start, field[n + 1].end, &id); + /* Field n+3 is optional. */ + if (id == -1 && fields > n+3) + isint_w(field[n + 3].start, field[n + 3].end, + &id); + + tag = 0; + s = field[n].start; + st = field[n].start + 1; + len = field[n].end - field[n].start; + + switch (*s) { + case L'u': + if (len == 1 || (len == 4 + && wmemcmp(st, L"ser", 3) == 0)) + tag = ARCHIVE_ENTRY_ACL_USER_OBJ; + break; + case L'g': + if (len == 1 || (len == 5 + && wmemcmp(st, L"roup", 4) == 0)) + tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ; + break; + case L'o': + if (len == 1 || (len == 5 + && wmemcmp(st, L"ther", 4) == 0)) + tag = ARCHIVE_ENTRY_ACL_OTHER; + break; + case L'm': + if (len == 1 || (len == 4 + && wmemcmp(st, L"ask", 3) == 0)) + tag = ARCHIVE_ENTRY_ACL_MASK; + break; + default: + break; + } + + switch (tag) { + case ARCHIVE_ENTRY_ACL_OTHER: + case ARCHIVE_ENTRY_ACL_MASK: + if (fields == (n + 2) + && field[n + 1].start < field[n + 1].end + && ismode_w(field[n + 1].start, + field[n + 1].end, &permset)) { + /* This is Solaris-style "other:rwx" */ + sol = 1; + } else if (fields == (n + 3) && + field[n + 1].start < field[n + 1].end) { + /* Invalid mask or other field */ + ret = ARCHIVE_WARN; + continue; + } + break; + case ARCHIVE_ENTRY_ACL_USER_OBJ: + case ARCHIVE_ENTRY_ACL_GROUP_OBJ: + if (id != -1 || + field[n + 1].start < field[n + 1].end) { + name = field[n + 1]; + if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) + tag = ARCHIVE_ENTRY_ACL_USER; + else + tag = ARCHIVE_ENTRY_ACL_GROUP; + } + break; + default: + /* Invalid tag, skip entry */ + ret = ARCHIVE_WARN; + continue; + } + + /* + * Without "default:" we expect mode in field 2 + * Exception: Solaris other and mask fields + */ + if (permset == 0 && !ismode_w(field[n + 2 - sol].start, + field[n + 2 - sol].end, &permset)) { + /* Invalid mode, skip entry */ + ret = ARCHIVE_WARN; + continue; + } + } else { + /* NFS4 ACLs */ + s = field[0].start; + len = field[0].end - field[0].start; + tag = 0; + + switch (len) { + case 4: + if (wmemcmp(s, L"user", 4) == 0) + tag = ARCHIVE_ENTRY_ACL_USER; + break; + case 5: + if (wmemcmp(s, L"group", 5) == 0) + tag = ARCHIVE_ENTRY_ACL_GROUP; + break; + case 6: + if (wmemcmp(s, L"owner@", 6) == 0) + tag = ARCHIVE_ENTRY_ACL_USER_OBJ; + else if (wmemcmp(s, L"group@", len) == 0) + tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ; + break; + case 9: + if (wmemcmp(s, L"everyone@", 9) == 0) + tag = ARCHIVE_ENTRY_ACL_EVERYONE; + default: + break; + } + + if (tag == 0) { + /* Invalid tag, skip entry */ + ret = ARCHIVE_WARN; + continue; + } else if (tag == ARCHIVE_ENTRY_ACL_USER || + tag == ARCHIVE_ENTRY_ACL_GROUP) { + n = 1; name = field[1]; + isint_w(name.start, name.end, &id); } else - tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ; - } else if (prefix_w(field[0].start, field[0].end, L"other")) { - if (fields == 2 - && field[1].start < field[1].end - && ismode_w(field[1].start, field[1].end, &permset)) { - /* This is Solaris-style "other:rwx" */ - } else if (fields == 3 - && field[1].start == field[1].end - && field[2].start < field[2].end - && ismode_w(field[2].start, field[2].end, &permset)) { - /* This is FreeBSD-style "other::rwx" */ - } else - return (ARCHIVE_WARN); - tag = ARCHIVE_ENTRY_ACL_OTHER; - } else if (prefix_w(field[0].start, field[0].end, L"mask")) { - if (fields == 2 - && field[1].start < field[1].end - && ismode_w(field[1].start, field[1].end, &permset)) { - /* This is Solaris-style "mask:rwx" */ - } else if (fields == 3 - && field[1].start == field[1].end - && field[2].start < field[2].end - && ismode_w(field[2].start, field[2].end, &permset)) { - /* This is FreeBSD-style "mask::rwx" */ - } else - return (ARCHIVE_WARN); - tag = ARCHIVE_ENTRY_ACL_MASK; - } else - return (ARCHIVE_WARN); + n = 0; + + if (!is_nfs4_perms_w(field[1 + n].start, + field[1 + n].end, &permset)) { + /* Invalid NFSv4 perms, skip entry */ + ret = ARCHIVE_WARN; + continue; + } + if (!is_nfs4_flags_w(field[2 + n].start, + field[2 + n].end, &permset)) { + /* Invalid NFSv4 flags, skip entry */ + ret = ARCHIVE_WARN; + continue; + } + s = field[3 + n].start; + len = field[3 + n].end - field[3 + n].start; + type = 0; + if (len == 4) { + if (wmemcmp(s, L"deny", 4) == 0) + type = ARCHIVE_ENTRY_ACL_TYPE_DENY; + } else if (len == 5) { + if (wmemcmp(s, L"allow", 5) == 0) + type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW; + else if (wmemcmp(s, L"audit", 5) == 0) + type = ARCHIVE_ENTRY_ACL_TYPE_AUDIT; + else if (wmemcmp(s, L"alarm", 5) == 0) + type = ARCHIVE_ENTRY_ACL_TYPE_ALARM; + } + if (type == 0) { + /* Invalid entry type, skip entry */ + ret = ARCHIVE_WARN; + continue; + } + isint_w(field[4 + n].start, field[4 + n].end, &id); + } /* Add entry to the internal list. */ - archive_acl_add_entry_w_len(acl, type, permset, + r = archive_acl_add_entry_w_len(acl, type, permset, tag, id, name.start, name.end - name.start); + if (r < ARCHIVE_WARN) + return (r); + if (r != ARCHIVE_OK) + ret = ARCHIVE_WARN; + types |= type; } - return (ARCHIVE_OK); + + /* Reset ACL */ + archive_acl_reset(acl, types); + + return (ret); } /* @@ -977,16 +1441,128 @@ ismode_w(const wchar_t *start, const wchar_t *end, int *permset) *permset = 0; while (p < end) { switch (*p++) { - case 'r': case 'R': + case L'r': case L'R': *permset |= ARCHIVE_ENTRY_ACL_READ; break; - case 'w': case 'W': + case L'w': case L'W': *permset |= ARCHIVE_ENTRY_ACL_WRITE; break; - case 'x': case 'X': + case L'x': case L'X': *permset |= ARCHIVE_ENTRY_ACL_EXECUTE; break; - case '-': + case L'-': + break; + default: + return (0); + } + } + return (1); +} + +/* + * Parse a string as a NFS4 ACL permission field. + * Returns true if the string is non-empty and consists only of NFS4 ACL + * permission characters, false otherwise + */ +static int +is_nfs4_perms_w(const wchar_t *start, const wchar_t *end, int *permset) +{ + const wchar_t *p; + + if (start >= end) + return (0); + p = start; + while (p < end) { + switch (*p++) { + case L'r': + *permset |= ARCHIVE_ENTRY_ACL_READ_DATA; + break; + case L'w': + *permset |= ARCHIVE_ENTRY_ACL_WRITE_DATA; + break; + case L'x': + *permset |= ARCHIVE_ENTRY_ACL_EXECUTE; + break; + case L'p': + *permset |= ARCHIVE_ENTRY_ACL_APPEND_DATA; + break; + case L'D': + *permset |= ARCHIVE_ENTRY_ACL_DELETE_CHILD; + break; + case L'd': + *permset |= ARCHIVE_ENTRY_ACL_DELETE; + break; + case L'a': + *permset |= ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES; + break; + case L'A': + *permset |= ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES; + break; + case L'R': + *permset |= ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS; + break; + case L'W': + *permset |= ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS; + break; + case L'c': + *permset |= ARCHIVE_ENTRY_ACL_READ_ACL; + break; + case L'C': + *permset |= ARCHIVE_ENTRY_ACL_WRITE_ACL; + break; + case L'o': + *permset |= ARCHIVE_ENTRY_ACL_WRITE_OWNER; + break; + case L's': + *permset |= ARCHIVE_ENTRY_ACL_SYNCHRONIZE; + break; + case L'-': + break; + default: + return(0); + } + } + return (1); +} + +/* + * Parse a string as a NFS4 ACL flags field. + * Returns true if the string is non-empty and consists only of NFS4 ACL + * flag characters, false otherwise + */ +static int +is_nfs4_flags_w(const wchar_t *start, const wchar_t *end, int *permset) +{ + const wchar_t *p; + + if (start >= end) + return (0); + p = start; + while (p < end) { + switch(*p++) { + case L'f': + *permset |= ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT; + break; + case L'd': + *permset |= ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT; + break; + case L'i': + *permset |= ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY; + break; + case L'n': + *permset |= + ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT; + break; + case L'S': + *permset |= ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS; + break; + case L'F': + *permset |= ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS; + break; + case L'I': + *permset |= ARCHIVE_ENTRY_ACL_ENTRY_INHERITED; + break; + case L'-': break; default: return (0); @@ -1033,46 +1609,48 @@ next_field_w(const wchar_t **wp, const wchar_t **start, } /* - * Return true if the characters [start...end) are a prefix of 'test'. - * This makes it easy to handle the obvious abbreviations: 'u' for 'user', etc. - */ -static int -prefix_w(const wchar_t *start, const wchar_t *end, const wchar_t *test) -{ - if (start == end) - return (0); - - if (*start++ != *test++) - return (0); - - while (start < end && *start++ == *test++) - ; - - if (start < end) - return (0); - - return (1); -} - -/* - * Parse a textual ACL. This automatically recognizes and supports - * extensions described above. The 'type' argument is used to - * indicate the type that should be used for any entries not - * explicitly marked as "default:". + * Parse an ACL text string. + * + * The want_type argument may be one of the following: + * ARCHIVE_ENTRY_ACL_TYPE_ACCESS - text is a POSIX.1e ACL of type ACCESS + * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - text is a POSIX.1e ACL of type DEFAULT + * ARCHIVE_ENTRY_ACL_TYPE_NFS4 - text is as a NFSv4 ACL + * + * POSIX.1e ACL entries prefixed with "default:" are treated as + * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT unless type is ARCHIVE_ENTRY_ACL_TYPE_NFS4 */ int -archive_acl_parse_l(struct archive_acl *acl, - const char *text, int default_type, struct archive_string_conv *sc) +archive_acl_from_text_l(struct archive_acl *acl, const char *text, + int want_type, struct archive_string_conv *sc) { struct { const char *start; const char *end; - } field[4], name; + } field[6], name; - int fields, n, r, ret = ARCHIVE_OK; - int type, tag, permset, id; + const char *s, *st; + int numfields, fields, n, r, sol, ret; + int type, types, tag, permset, id; + size_t len; char sep; + switch (want_type) { + case ARCHIVE_ENTRY_ACL_TYPE_POSIX1E: + want_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS; + case ARCHIVE_ENTRY_ACL_TYPE_ACCESS: + case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT: + numfields = 5; + break; + case ARCHIVE_ENTRY_ACL_TYPE_NFS4: + numfields = 6; + break; + default: + return (ARCHIVE_FATAL); + } + + ret = ARCHIVE_OK; + types = 0; + while (text != NULL && *text != '\0') { /* * Parse the fields out of the next entry, @@ -1082,7 +1660,7 @@ archive_acl_parse_l(struct archive_acl *acl, do { const char *start, *end; next_field(&text, &start, &end, &sep); - if (fields < 4) { + if (fields < numfields) { field[fields].start = start; field[fields].end = end; } @@ -1090,72 +1668,197 @@ archive_acl_parse_l(struct archive_acl *acl, } while (sep == ':'); /* Set remaining fields to blank. */ - for (n = fields; n < 4; ++n) + for (n = fields; n < numfields; ++n) field[n].start = field[n].end = NULL; - /* Check for a numeric ID in field 1 or 3. */ - id = -1; - isint(field[1].start, field[1].end, &id); - /* Field 3 is optional. */ - if (id == -1 && fields > 3) - isint(field[3].start, field[3].end, &id); - - /* - * Solaris extension: "defaultuser::rwx" is the - * default ACL corresponding to "user::rwx", etc. - */ - if (field[0].end - field[0].start > 7 - && memcmp(field[0].start, "default", 7) == 0) { - type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT; - field[0].start += 7; - } else - type = default_type; + if (field[0].start != NULL && *(field[0].start) == '#') { + /* Comment, skip entry */ + continue; + } + n = 0; + sol = 0; + id = -1; + permset = 0; name.start = name.end = NULL; - if (prefix_c(field[0].start, field[0].end, "user")) { - if (!ismode(field[2].start, field[2].end, &permset)) - return (ARCHIVE_WARN); - if (id != -1 || field[1].start < field[1].end) { - tag = ARCHIVE_ENTRY_ACL_USER; - name = field[1]; + + if (want_type != ARCHIVE_ENTRY_ACL_TYPE_NFS4) { + /* POSIX.1e ACLs */ + /* + * Default keyword "default:user::rwx" + * if found, we have one more field + * + * We also support old Solaris extension: + * "defaultuser::rwx" is the default ACL corresponding + * to "user::rwx", etc. valid only for first field + */ + s = field[0].start; + len = field[0].end - field[0].start; + if (*s == 'd' && (len == 1 || (len >= 7 + && memcmp((s + 1), "efault", 6) == 0))) { + type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT; + if (len > 7) + field[0].start += 7; + else + n = 1; } else - tag = ARCHIVE_ENTRY_ACL_USER_OBJ; - } else if (prefix_c(field[0].start, field[0].end, "group")) { - if (!ismode(field[2].start, field[2].end, &permset)) - return (ARCHIVE_WARN); - if (id != -1 || field[1].start < field[1].end) { - tag = ARCHIVE_ENTRY_ACL_GROUP; + type = want_type; + + /* Check for a numeric ID in field n+1 or n+3. */ + isint(field[n + 1].start, field[n + 1].end, &id); + /* Field n+3 is optional. */ + if (id == -1 && fields > (n + 3)) + isint(field[n + 3].start, field[n + 3].end, + &id); + + tag = 0; + s = field[n].start; + st = field[n].start + 1; + len = field[n].end - field[n].start; + + switch (*s) { + case 'u': + if (len == 1 || (len == 4 + && memcmp(st, "ser", 3) == 0)) + tag = ARCHIVE_ENTRY_ACL_USER_OBJ; + break; + case 'g': + if (len == 1 || (len == 5 + && memcmp(st, "roup", 4) == 0)) + tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ; + break; + case 'o': + if (len == 1 || (len == 5 + && memcmp(st, "ther", 4) == 0)) + tag = ARCHIVE_ENTRY_ACL_OTHER; + break; + case 'm': + if (len == 1 || (len == 4 + && memcmp(st, "ask", 3) == 0)) + tag = ARCHIVE_ENTRY_ACL_MASK; + break; + default: + break; + } + + switch (tag) { + case ARCHIVE_ENTRY_ACL_OTHER: + case ARCHIVE_ENTRY_ACL_MASK: + if (fields == (n + 2) + && field[n + 1].start < field[n + 1].end + && ismode(field[n + 1].start, + field[n + 1].end, &permset)) { + /* This is Solaris-style "other:rwx" */ + sol = 1; + } else if (fields == (n + 3) && + field[n + 1].start < field[n + 1].end) { + /* Invalid mask or other field */ + ret = ARCHIVE_WARN; + continue; + } + break; + case ARCHIVE_ENTRY_ACL_USER_OBJ: + case ARCHIVE_ENTRY_ACL_GROUP_OBJ: + if (id != -1 || + field[n + 1].start < field[n + 1].end) { + name = field[n + 1]; + if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) + tag = ARCHIVE_ENTRY_ACL_USER; + else + tag = ARCHIVE_ENTRY_ACL_GROUP; + } + break; + default: + /* Invalid tag, skip entry */ + ret = ARCHIVE_WARN; + continue; + } + + /* + * Without "default:" we expect mode in field 3 + * Exception: Solaris other and mask fields + */ + if (permset == 0 && !ismode(field[n + 2 - sol].start, + field[n + 2 - sol].end, &permset)) { + /* Invalid mode, skip entry */ + ret = ARCHIVE_WARN; + continue; + } + } else { + /* NFS4 ACLs */ + s = field[0].start; + len = field[0].end - field[0].start; + tag = 0; + + switch (len) { + case 4: + if (memcmp(s, "user", 4) == 0) + tag = ARCHIVE_ENTRY_ACL_USER; + break; + case 5: + if (memcmp(s, "group", 5) == 0) + tag = ARCHIVE_ENTRY_ACL_GROUP; + break; + case 6: + if (memcmp(s, "owner@", 6) == 0) + tag = ARCHIVE_ENTRY_ACL_USER_OBJ; + else if (memcmp(s, "group@", 6) == 0) + tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ; + break; + case 9: + if (memcmp(s, "everyone@", 9) == 0) + tag = ARCHIVE_ENTRY_ACL_EVERYONE; + break; + default: + break; + } + + if (tag == 0) { + /* Invalid tag, skip entry */ + ret = ARCHIVE_WARN; + continue; + } else if (tag == ARCHIVE_ENTRY_ACL_USER || + tag == ARCHIVE_ENTRY_ACL_GROUP) { + n = 1; name = field[1]; + isint(name.start, name.end, &id); } else - tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ; - } else if (prefix_c(field[0].start, field[0].end, "other")) { - if (fields == 2 - && field[1].start < field[1].end - && ismode(field[1].start, field[1].end, &permset)) { - /* This is Solaris-style "other:rwx" */ - } else if (fields == 3 - && field[1].start == field[1].end - && field[2].start < field[2].end - && ismode(field[2].start, field[2].end, &permset)) { - /* This is FreeBSD-style "other::rwx" */ - } else - return (ARCHIVE_WARN); - tag = ARCHIVE_ENTRY_ACL_OTHER; - } else if (prefix_c(field[0].start, field[0].end, "mask")) { - if (fields == 2 - && field[1].start < field[1].end - && ismode(field[1].start, field[1].end, &permset)) { - /* This is Solaris-style "mask:rwx" */ - } else if (fields == 3 - && field[1].start == field[1].end - && field[2].start < field[2].end - && ismode(field[2].start, field[2].end, &permset)) { - /* This is FreeBSD-style "mask::rwx" */ - } else - return (ARCHIVE_WARN); - tag = ARCHIVE_ENTRY_ACL_MASK; - } else - return (ARCHIVE_WARN); + n = 0; + + if (!is_nfs4_perms(field[1 + n].start, + field[1 + n].end, &permset)) { + /* Invalid NFSv4 perms, skip entry */ + ret = ARCHIVE_WARN; + continue; + } + if (!is_nfs4_flags(field[2 + n].start, + field[2 + n].end, &permset)) { + /* Invalid NFSv4 flags, skip entry */ + ret = ARCHIVE_WARN; + continue; + } + s = field[3 + n].start; + len = field[3 + n].end - field[3 + n].start; + type = 0; + if (len == 4) { + if (memcmp(s, "deny", 4) == 0) + type = ARCHIVE_ENTRY_ACL_TYPE_DENY; + } else if (len == 5) { + if (memcmp(s, "allow", 5) == 0) + type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW; + else if (memcmp(s, "audit", 5) == 0) + type = ARCHIVE_ENTRY_ACL_TYPE_AUDIT; + else if (memcmp(s, "alarm", 5) == 0) + type = ARCHIVE_ENTRY_ACL_TYPE_ALARM; + } + if (type == 0) { + /* Invalid entry type, skip entry */ + ret = ARCHIVE_WARN; + continue; + } + isint(field[4 + n].start, field[4 + n].end, + &id); + } /* Add entry to the internal list. */ r = archive_acl_add_entry_len_l(acl, type, permset, @@ -1164,7 +1867,12 @@ archive_acl_parse_l(struct archive_acl *acl, return (r); if (r != ARCHIVE_OK) ret = ARCHIVE_WARN; + types |= type; } + + /* Reset ACL */ + archive_acl_reset(acl, types); + return (ret); } @@ -1230,6 +1938,118 @@ ismode(const char *start, const char *end, int *permset) } /* + * Parse a string as a NFS4 ACL permission field. + * Returns true if the string is non-empty and consists only of NFS4 ACL + * permission characters, false otherwise + */ +static int +is_nfs4_perms(const char *start, const char *end, int *permset) +{ + const char *p; + + if (start >= end) + return (0); + p = start; + while (p < end) { + switch (*p++) { + case 'r': + *permset |= ARCHIVE_ENTRY_ACL_READ_DATA; + break; + case 'w': + *permset |= ARCHIVE_ENTRY_ACL_WRITE_DATA; + break; + case 'x': + *permset |= ARCHIVE_ENTRY_ACL_EXECUTE; + break; + case 'p': + *permset |= ARCHIVE_ENTRY_ACL_APPEND_DATA; + break; + case 'D': + *permset |= ARCHIVE_ENTRY_ACL_DELETE_CHILD; + break; + case 'd': + *permset |= ARCHIVE_ENTRY_ACL_DELETE; + break; + case 'a': + *permset |= ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES; + break; + case 'A': + *permset |= ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES; + break; + case 'R': + *permset |= ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS; + break; + case 'W': + *permset |= ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS; + break; + case 'c': + *permset |= ARCHIVE_ENTRY_ACL_READ_ACL; + break; + case 'C': + *permset |= ARCHIVE_ENTRY_ACL_WRITE_ACL; + break; + case 'o': + *permset |= ARCHIVE_ENTRY_ACL_WRITE_OWNER; + break; + case 's': + *permset |= ARCHIVE_ENTRY_ACL_SYNCHRONIZE; + break; + case '-': + break; + default: + return(0); + } + } + return (1); +} + +/* + * Parse a string as a NFS4 ACL flags field. + * Returns true if the string is non-empty and consists only of NFS4 ACL + * flag characters, false otherwise + */ +static int +is_nfs4_flags(const char *start, const char *end, int *permset) +{ + const char *p; + + if (start >= end) + return (0); + p = start; + while (p < end) { + switch(*p++) { + case 'f': + *permset |= ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT; + break; + case 'd': + *permset |= ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT; + break; + case 'i': + *permset |= ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY; + break; + case 'n': + *permset |= + ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT; + break; + case 'S': + *permset |= ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS; + break; + case 'F': + *permset |= ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS; + break; + case 'I': + *permset |= ARCHIVE_ENTRY_ACL_ENTRY_INHERITED; + break; + case '-': + break; + default: + return (0); + } + } + return (1); +} + +/* * Match "[:whitespace:]*(.*)[:whitespace:]*[:,\n]". *wp is updated * to point to just after the separator. *start points to the first * character of the matched text and *end just after the last @@ -1264,25 +2084,3 @@ next_field(const char **p, const char **start, if (**p != '\0') (*p)++; } - -/* - * Return true if the characters [start...end) are a prefix of 'test'. - * This makes it easy to handle the obvious abbreviations: 'u' for 'user', etc. - */ -static int -prefix_c(const char *start, const char *end, const char *test) -{ - if (start == end) - return (0); - - if (*start++ != *test++) - return (0); - - while (start < end && *start++ == *test++) - ; - - if (start < end) - return (0); - - return (1); -} diff --git a/contrib/libarchive/libarchive/archive_acl_private.h b/contrib/libarchive/libarchive/archive_acl_private.h index 1421adb..ef0b023 100644 --- a/contrib/libarchive/libarchive/archive_acl_private.h +++ b/contrib/libarchive/libarchive/archive_acl_private.h @@ -56,6 +56,7 @@ struct archive_acl { void archive_acl_clear(struct archive_acl *); void archive_acl_copy(struct archive_acl *, struct archive_acl *); int archive_acl_count(struct archive_acl *, int); +int archive_acl_types(struct archive_acl *); int archive_acl_reset(struct archive_acl *, int); int archive_acl_next(struct archive *, struct archive_acl *, int, int *, int *, int *, int *, const char **); @@ -66,22 +67,17 @@ int archive_acl_add_entry_w_len(struct archive_acl *, int archive_acl_add_entry_len(struct archive_acl *, int, int, int, int, const char *, size_t); -const wchar_t *archive_acl_text_w(struct archive *, struct archive_acl *, int); -int archive_acl_text_l(struct archive_acl *, int, const char **, size_t *, +wchar_t *archive_acl_to_text_w(struct archive_acl *, ssize_t *, int, + struct archive *); +char *archive_acl_to_text_l(struct archive_acl *, ssize_t *, int, struct archive_string_conv *); /* - * Private ACL parser. This is private because it handles some - * very weird formats that clients should not be messing with. - * Clients should only deal with their platform-native formats. - * Because of the need to support many formats cleanly, new arguments - * are likely to get added on a regular basis. Clients who try to use - * this interface are likely to be surprised when it changes. + * ACL text parser. */ -int archive_acl_parse_w(struct archive_acl *, - const wchar_t *, int /* type */); -int archive_acl_parse_l(struct archive_acl *, - const char *, int /* type */, - struct archive_string_conv *); +int archive_acl_from_text_w(struct archive_acl *, const wchar_t * /* wtext */, + int /* type */); +int archive_acl_from_text_l(struct archive_acl *, const char * /* text */, + int /* type */, struct archive_string_conv *); #endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */ diff --git a/contrib/libarchive/libarchive/archive_entry.c b/contrib/libarchive/libarchive/archive_entry.c index f240025..556c402 100644 --- a/contrib/libarchive/libarchive/archive_entry.c +++ b/contrib/libarchive/libarchive/archive_entry.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2016 Martin Matuska * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1446,7 +1447,7 @@ archive_entry_acl_add_entry_w(struct archive_entry *entry, int archive_entry_acl_types(struct archive_entry *entry) { - return ((&entry->acl)->acl_types); + return (archive_acl_types(&entry->acl)); } /* @@ -1486,34 +1487,121 @@ archive_entry_acl_next(struct archive_entry *entry, int want_type, int *type, } /* - * Generate a text version of the ACL. The flags parameter controls + * Generate a text version of the ACL. The flags parameter controls * the style of the generated ACL. */ +wchar_t * +archive_entry_acl_to_text_w(struct archive_entry *entry, ssize_t *len, + int flags) +{ + return (archive_acl_to_text_w(&entry->acl, len, flags, + entry->archive)); +} + +char * +archive_entry_acl_to_text(struct archive_entry *entry, ssize_t *len, + int flags) +{ + return (archive_acl_to_text_l(&entry->acl, len, flags, NULL)); +} + +char * +_archive_entry_acl_to_text_l(struct archive_entry *entry, ssize_t *len, + int flags, struct archive_string_conv *sc) +{ + return (archive_acl_to_text_l(&entry->acl, len, flags, sc)); +} + +/* + * ACL text parser. + */ +int +archive_entry_acl_from_text_w(struct archive_entry *entry, + const wchar_t *wtext, int type) +{ + return (archive_acl_from_text_w(&entry->acl, wtext, type)); +} + +int +archive_entry_acl_from_text(struct archive_entry *entry, + const char *text, int type) +{ + return (archive_acl_from_text_l(&entry->acl, text, type, NULL)); +} + +int +_archive_entry_acl_from_text_l(struct archive_entry *entry, const char *text, + int type, struct archive_string_conv *sc) +{ + return (archive_acl_from_text_l(&entry->acl, text, type, sc)); +} + +/* Deprecated */ +static int +archive_entry_acl_text_compat(int *flags) +{ + if ((*flags & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) == 0) + return (1); + + /* ABI compat with old ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID */ + if ((*flags & OLD_ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID) != 0) + *flags |= ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID; + + /* ABI compat with old ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT */ + if ((*flags & OLD_ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT) != 0) + *flags |= ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT; + + *flags |= ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA; + + return (0); +} + +/* Deprecated */ const wchar_t * archive_entry_acl_text_w(struct archive_entry *entry, int flags) { - const wchar_t *r; - r = archive_acl_text_w(entry->archive, &entry->acl, flags); - if (r == NULL && errno == ENOMEM) - __archive_errx(1, "No memory"); - return (r); + if (entry->acl.acl_text_w != NULL) { + free(entry->acl.acl_text_w); + entry->acl.acl_text_w = NULL; + } + if (archive_entry_acl_text_compat(&flags) == 0) + entry->acl.acl_text_w = archive_acl_to_text_w(&entry->acl, + NULL, flags, entry->archive); + return (entry->acl.acl_text_w); } +/* Deprecated */ const char * archive_entry_acl_text(struct archive_entry *entry, int flags) { - const char *p; - if (archive_acl_text_l(&entry->acl, flags, &p, NULL, NULL) != 0 - && errno == ENOMEM) - __archive_errx(1, "No memory"); - return (p); + if (entry->acl.acl_text != NULL) { + free(entry->acl.acl_text); + entry->acl.acl_text = NULL; + } + if (archive_entry_acl_text_compat(&flags) == 0) + entry->acl.acl_text = archive_acl_to_text_l(&entry->acl, NULL, + flags, NULL); + + return (entry->acl.acl_text); } +/* Deprecated */ int _archive_entry_acl_text_l(struct archive_entry *entry, int flags, const char **acl_text, size_t *len, struct archive_string_conv *sc) { - return (archive_acl_text_l(&entry->acl, flags, acl_text, len, sc)); + if (entry->acl.acl_text != NULL) { + free(entry->acl.acl_text); + entry->acl.acl_text = NULL; + } + + if (archive_entry_acl_text_compat(&flags) == 0) + entry->acl.acl_text = archive_acl_to_text_l(&entry->acl, + (ssize_t *)len, flags, sc); + + *acl_text = entry->acl.acl_text; + + return (0); } /* diff --git a/contrib/libarchive/libarchive/archive_entry.h b/contrib/libarchive/libarchive/archive_entry.h index 27c473e..42180c4 100644 --- a/contrib/libarchive/libarchive/archive_entry.h +++ b/contrib/libarchive/libarchive/archive_entry.h @@ -1,5 +1,6 @@ /*- * Copyright (c) 2003-2008 Tim Kientzle + * Copyright (c) 2016 Martin Matuska * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -104,6 +105,12 @@ typedef int64_t la_int64_t; # define __LA_DECL #endif +#if defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >= 1 +# define __LA_DEPRECATED __attribute__((deprecated)) +#else +# define __LA_DEPRECATED +#endif + #ifdef __cplusplus extern "C" { #endif @@ -420,6 +427,7 @@ __LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const voi /* * Inheritance values (NFS4 ACLs only); included in permset. */ +#define ARCHIVE_ENTRY_ACL_ENTRY_INHERITED 0x01000000 #define ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT 0x02000000 #define ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT 0x04000000 #define ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT 0x08000000 @@ -433,15 +441,16 @@ __LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const voi | ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT \ | ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY \ | ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS \ - | ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS) + | ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS \ + | ARCHIVE_ENTRY_ACL_ENTRY_INHERITED) /* We need to be able to specify combinations of these. */ -#define ARCHIVE_ENTRY_ACL_TYPE_ACCESS 256 /* POSIX.1e only */ -#define ARCHIVE_ENTRY_ACL_TYPE_DEFAULT 512 /* POSIX.1e only */ -#define ARCHIVE_ENTRY_ACL_TYPE_ALLOW 1024 /* NFS4 only */ -#define ARCHIVE_ENTRY_ACL_TYPE_DENY 2048 /* NFS4 only */ -#define ARCHIVE_ENTRY_ACL_TYPE_AUDIT 4096 /* NFS4 only */ -#define ARCHIVE_ENTRY_ACL_TYPE_ALARM 8192 /* NFS4 only */ +#define ARCHIVE_ENTRY_ACL_TYPE_ACCESS 0x00000100 /* POSIX.1e only */ +#define ARCHIVE_ENTRY_ACL_TYPE_DEFAULT 0x00000200 /* POSIX.1e only */ +#define ARCHIVE_ENTRY_ACL_TYPE_ALLOW 0x00000400 /* NFS4 only */ +#define ARCHIVE_ENTRY_ACL_TYPE_DENY 0x00000800 /* NFS4 only */ +#define ARCHIVE_ENTRY_ACL_TYPE_AUDIT 0x00001000 /* NFS4 only */ +#define ARCHIVE_ENTRY_ACL_TYPE_ALARM 0x00002000 /* NFS4 only */ #define ARCHIVE_ENTRY_ACL_TYPE_POSIX1E (ARCHIVE_ENTRY_ACL_TYPE_ACCESS \ | ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) #define ARCHIVE_ENTRY_ACL_TYPE_NFS4 (ARCHIVE_ENTRY_ACL_TYPE_ALLOW \ @@ -492,21 +501,43 @@ __LA_DECL int archive_entry_acl_next_w(struct archive_entry *, int /* want_type * Construct a text-format ACL. The flags argument is a bitmask that * can include any of the following: * + * Flags only for archive entries with POSIX.1e ACL: * ARCHIVE_ENTRY_ACL_TYPE_ACCESS - Include POSIX.1e "access" entries. * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - Include POSIX.1e "default" entries. - * ARCHIVE_ENTRY_ACL_TYPE_NFS4 - Include NFS4 entries. - * ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID - Include extra numeric ID field in - * each ACL entry. ('star' introduced this for POSIX.1e, this flag - * also applies to NFS4.) * ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT - Include "default:" before each - * default ACL entry, as used in old Solaris ACLs. + * default ACL entry. + * ARCHIVE_ENTRY_ACL_STYLE_SOLARIS - Output only one colon after "other" and + * "mask" entries. + * + * Flags for for archive entries with POSIX.1e ACL or NFSv4 ACL: + * ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID - Include extra numeric ID field in + * each ACL entry. + * ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA - Separate entries with comma + * instead of newline. */ -#define ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 1024 -#define ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 2048 +#define ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 0x00000001 +#define ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 0x00000002 +#define ARCHIVE_ENTRY_ACL_STYLE_SOLARIS 0x00000004 +#define ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA 0x00000008 + +__LA_DECL wchar_t *archive_entry_acl_to_text_w(struct archive_entry *, + ssize_t * /* len */, int /* flags */); +__LA_DECL char *archive_entry_acl_to_text(struct archive_entry *, + ssize_t * /* len */, int /* flags */); +__LA_DECL int archive_entry_acl_from_text_w(struct archive_entry *, + const wchar_t * /* wtext */, int /* type */); +__LA_DECL int archive_entry_acl_from_text(struct archive_entry *, + const char * /* text */, int /* type */); + +/* Deprecated constants */ +#define OLD_ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 1024 +#define OLD_ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 2048 + +/* Deprecated functions */ __LA_DECL const wchar_t *archive_entry_acl_text_w(struct archive_entry *, - int /* flags */); + int /* flags */) __LA_DEPRECATED; __LA_DECL const char *archive_entry_acl_text(struct archive_entry *, - int /* flags */); + int /* flags */) __LA_DEPRECATED; /* Return bitmask of ACL types in an archive entry */ __LA_DECL int archive_entry_acl_types(struct archive_entry *); diff --git a/contrib/libarchive/libarchive/archive_entry_acl.3 b/contrib/libarchive/libarchive/archive_entry_acl.3 index e85c4de..93707d1 100644 --- a/contrib/libarchive/libarchive/archive_entry_acl.3 +++ b/contrib/libarchive/libarchive/archive_entry_acl.3 @@ -1,4 +1,5 @@ .\" Copyright (c) 2010 Joerg Sonnenberger +.\" Copyright (c) 2016 Martin Matuska .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -22,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd February 2, 2012 +.Dd December 27, 2016 .Dt ARCHIVE_ENTRY_ACL 3 .Os .Sh NAME @@ -30,10 +31,13 @@ .Nm archive_entry_acl_add_entry_w , .Nm archive_entry_acl_clear , .Nm archive_entry_acl_count , +.Nm archive_entry_acl_from_text , +.Nm archive_entry_acl_from_text_w, .Nm archive_entry_acl_next , .Nm archive_entry_acl_next_w , .Nm archive_entry_acl_reset , -.Nm archive_entry_acl_text_w , +.Nm archive_entry_acl_to_text , +.Nm archive_entry_acl_to_text_w , .Nm archive_entry_acl_types .Nd functions for manipulating Access Control Lists in archive entry descriptions .Sh LIBRARY @@ -63,6 +67,18 @@ Streaming Archive Library (libarchive, -larchive) .Ft int .Fn archive_entry_acl_count "struct archive_entry *a" "int type" .Ft int +.Fo archive_entry_acl_from_text +.Fa "struct archive_entry *a" +.Fa "const char *text" +.Fa "int type" +.Fc +.Ft int +.Fo archive_entry_acl_from_text_w +.Fa "struct archive_entry *a" +.Fa "const wchar_t *text" +.Fa "int type" +.Fc +.Ft int .Fo archive_entry_acl_next .Fa "struct archive_entry *a" .Fa "int type" @@ -84,33 +100,48 @@ Streaming Archive Library (libarchive, -larchive) .Fc .Ft int .Fn archive_entry_acl_reset "struct archive_entry *a" "int type" -.Ft const wchar_t * -.Fn archive_entry_acl_text_w "struct archive_entry *a" "int flags" +.Ft char * +.Fo archive_entry_acl_to_text +.Fa "struct archive_entry *a" +.Fa "ssize_t *len_p" +.Fa "int flags" +.Fc +.Ft wchar_t * +.Fo archive_entry_acl_to_text_w +.Fa "struct archive_entry *a" +.Fa "ssize_t *len_p" +.Fa "int flags" +.Fc .Ft int .Fn archive_entry_acl_types "struct archive_entry *a" .\" enum? .Sh DESCRIPTION -An -.Dq Access Control List -is a generalisation of the classic Unix permission system. +The +.Dq Access Control Lists (ACLs) +extend the standard Unix perssion model. The ACL interface of .Nm libarchive -is derived from the POSIX.1e draft, but restricted to simplify dealing -with practical implementations in various Operating Systems and archive formats. -.Pp -An ACL consists of a number of independent entries. +supports both POSIX.1e and NFSv4 style ACLs. Use of ACLs is restricted by +various levels of ACL support in operating systems, file systems and archive +formats. +.Ss POSIX.1e Access Control Lists +A POSIX.1e ACL consists of a number of independent entries. Each entry specifies the permission set as bitmask of basic permissions. -Valid permissions are: +Valid permissions in the +.Fa permset +are: .Bl -tag -offset indent -compact -width "ARCHIVE_ENTRY_ACL_EXECUTE" -.It Dv ARCHIVE_ENTRY_ACL_EXECUTE -.It Dv ARCHIVE_ENTRY_ACL_WRITE -.It Dv ARCHIVE_ENTRY_ACL_READ +.It Dv ARCHIVE_ENTRY_ACL_READ ( Sy r ) +.It Dv ARCHIVE_ENTRY_ACL_WRITE ( Sy w ) +.It Dv ARCHIVE_ENTRY_ACL_EXECUTE ( Sy x ) .El The permissions correspond to the normal Unix permissions. .Pp -The tag specifies the principal to which the permission applies. +The +.Fa tag +specifies the principal to which the permission applies. Valid values are: -.Bl -tag -offset indent -compact -width "ARCHIVE_ENTRY_ACL_GROUP_OBJ" +.Bl -hang -offset indent -compact -width "ARCHIVE_ENTRY_ACL_GROUP_OBJ" .It Dv ARCHIVE_ENTRY_ACL_USER The user specified by the name field. .It Dv ARCHIVE_ENTRY_ACL_USER_OBJ @@ -122,8 +153,9 @@ The group who owns the file. .It Dv ARCHIVE_ENTRY_ACL_MASK The maximum permissions to be obtained via group permissions. .It Dv ARCHIVE_ENTRY_ACL_OTHER -Any principal who doesn't have a user or group entry. +Any principal who is not file owner or a member of the owning group. .El +.Pp The principals .Dv ARCHIVE_ENTRY_ACL_USER_OBJ , .Dv ARCHIVE_ENTRY_ACL_GROUP_OBJ @@ -132,19 +164,123 @@ and are equivalent to user, group and other in the classic Unix permission model and specify non-extended ACL entries. .Pp -All files have an access ACL +All files with have an access ACL .Pq Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS . This specifies the permissions required for access to the file itself. Directories have an additional ACL .Pq Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT , which controls the initial access ACL for newly created directory entries. +.Ss NFSv4 Access Control Lists +A NFSv4 ACL consists of multiple individual entries called Access Control +Entries (ACEs). +.Pp +There are four possible types of a NFSv4 ACE: +.Bl -hang -offset indent -compact -width "ARCHIVE_ENTRY_ACL_TYE_ALLOW" +.It Dv ARCHIVE_ENTRY_ACL_TYPE_ALLOW +Allow principal to perform actions requiring given permissions. +.It Dv ARCHIVE_ENTRY_ACL_TYPE_DENY +Prevent principal from performing actions requiring given permissions. +.It Dv ARCHIVE_ENTRY_ACL_TYPE_AUDIT +Log access attempts by principal which require given permissions. +.It Dv ARCHIVE_ENTRY_ACL_TYPE_ALARM +Trigger a system alarm on access attempts by principal which require given +permissions. +.El +.Pp +The +.Fa tag +specifies the principal to which the permission applies. +Valid values are: +.Bl -hang -offset indent -compact -width "ARCHIVE_ENTRY_ACL_GROUP_OBJ" +.It Dv ARCHIVE_ENTRY_ACL_USER +The user specified by the name field. +.It Dv ARCHIVE_ENTRY_ACL_USER_OBJ +The owner of the file. +.It Dv ARCHIVE_ENTRY_ACL_GROUP +The group specied by the name field. +.It Dv ARCHIVE_ENTRY_ACL_GROUP_OBJ +The group who owns the file. +.It Dv ARCHIVE_ENTRY_ACL_EVERYONE +Any principal who is not file owner or a member of the owning group. +.El +.Pp +Entries with the +.Dv ARCHIVE_ENTRY_ACL_USER +or +.Dv ARCHIVE_ENTRY_ACL_GROUP +tag store the user and group name in the +.Fa name +string and optionally the user or group ID in the +.Fa qualifier +integer. .Pp +NFSv4 ACE permissions and flags are stored in the same +.Fa permset +bitfield. Some permissions share the same constant and permission character but +have different effect on directories than on files. The following ACE +permissions are supported: +.Bl -tag -offset indent -compact -width ARCHIV +.It Dv ARCHIVE_ENTRY_ACL_READ_DATA ( Sy r ) +Read data (file). +.It Dv ARCHIVE_ENTRY_ACL_LIST_DIRECTORY ( Sy r ) +List entries (directory). +.It ARCHIVE_ENTRY_ACL_WRITE_DATA ( Sy w ) +Write data (file). +.It ARCHIVE_ENTRY_ACL_ADD_FILE ( Sy w ) +Create files (directory). +.It Dv ARCHIVE_ENTRY_ACL_EXECUTE ( Sy x ) +Execute file or change into a directory. +.It Dv ARCHIVE_ENTRY_ACL_APPEND_DATA ( Sy p ) +Append data (file). +.It Dv ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY ( Sy p ) +Create subdirectories (directory). +.It Dv ARCHIVE_ENTRY_ACL_DELETE_CHILD ( Sy D ) +Remove files and subdirectories inside a directory. +.It Dv ARCHIVE_ENTRY_ACL_DELETE ( Sy d ) +Remove file or directory. +.It Dv ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES ( Sy a ) +Read file or directory attributes. +.It Dv ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES ( Sy A ) +Write file or directory attributes. +.It Dv ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS ( Sy R ) +Read named file or directory attributes. +.It Dv ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS ( Sy W ) +Write named file or directory attributes. +.It Dv ARCHIVE_ENTRY_ACL_READ_ACL ( Sy c ) +Read file or directory ACL. +.It Dv ARCHIVE_ENTRY_ACL_WRITE_ACL ( Sy C ) +Write file or directory ACL. +.It Dv ARCHIVE_ENTRY_ACL_WRITE_OWNER ( Sy o ) +Change owner of a file or directory. +.It Dv ARCHIVE_ENTRY_ACL_SYNCHRONIZE ( Sy s ) +Use synchronous I/O. +.El +.Pp +The following NFSv4 ACL inheritance flags are supported: +.Bl -tag -offset indent -compact -width ARCHIV +.It Dv ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT ( Sy f ) +Inherit parent directory ACE to files. +.It Dv ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT ( Sy d ) +Inherit parent directory ACE to subdirectories. +.It Dv ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY ( Sy i ) +Only inherit, do not apply the permission on the directory itself. +.It Dv ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT ( Sy n ) +Do not propagate inherit flags. Only first-level entries inherit ACLs. +.It Dv ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS ( Sy S ) +Trigger alarm or audit on succesful access. +.It Dv ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS ( Sy F ) +Trigger alarm or audit on failed access. +.It Dv ARCHIVE_ENTRY_ACL_ENTRY_INHERITED ( Sy I ) +Mark that ACE was inherited. +.El +.Ss Functions .Fn archive_entry_acl_add_entry and .Fn archive_entry_acl_add_entry_w add a single ACL entry. For the access ACL and non-extended principals, the classic Unix permissions -are updated. +are updated. An archive enry cannot contain both POSIX.1e and NFSv4 ACL +entries. .Pp .Fn archive_entry_acl_clear removes all ACL entries and resets the enumeration pointer. @@ -153,14 +289,58 @@ removes all ACL entries and resets the enumeration pointer. counts the ACL entries that have the given type mask. .Fa type can be the bitwise-or of -.Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS -and -.Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT . -If +.Bl -tag -offset indent -compact -width "ARCHIVE_ENTRY_ACL_TYPE_DEFAULT" +.It Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS +.It Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT +.El +for POSIX.1e ACLs and +.Bl -tag -offset indent -compact -width "ARCHIVE_ENTRY_ACL_TYPE_ALLOW" +.It Dv ARCHIVE_ENTRY_ACL_TYPE_ALLOW +.It Dv ARCHIVE_ENTRY_ACL_TYPE_DENY +.It Dv ARCHIVE_ENTRY_ACL_TYPE_AUDIT +.It Dv ARCHIVE_ENTRY_ACL_TYPE_ALARM +.El +for NFSv4 ACLs. For POSIX.1e ACLs if .Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS is included and at least one extended ACL entry is found, the three non-extened ACLs are added. .Pp +.Fn archive_entry_acl_from_text +and +.Fn archive_entry_acl_from_text_w +add new +.Pq or merge with existing +ACL entries from +.Pq wide +text. The argument +.Fa type +may take one of the following values: +.Bl -tag -offset indent -compact -width "ARCHIVE_ENTRY_ACL_TYPE_DEFAULT" +.It Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS +.It Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT +.It Dv ARCHIVE_ENTRY_ACL_TYPE_NFS4 +.El +Supports all formats that can be created with +.Fn archive_entry_acl_to_text +or respective +.Fn archive_entry_acl_to_text_w . +Existing ACL entries are preserved. To get a clean new ACL from text +.Fn archive_entry_acl_clear +must be called first. Entries prefixed with +.Dq default: +are treated as +.Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT +unless +.Fa type +is +.Dv ARCHIVE_ENTRY_ACL_TYPE_NFS4 . +Invalid entries, non-parseable ACL entries and entries beginning with +the +.Sq # +character +.Pq comments +are skipped. +.Pp .Fn archive_entry_acl_next and .Fn archive_entry_acl_next_w @@ -182,19 +362,50 @@ or set using Otherwise, the function returns the same value as .Fn archive_entry_acl_count . .Pp -.Fn archive_entry_acl_text_w -converts the ACL entries for the given type mask into a wide string. -In addition to the normal type flags, -.Dv ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID +.Fn archive_entry_acl_to_text and -.Dv ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT -can be specified to further customize the result. -The returned long string is valid until the next call to -.Fn archive_entry_acl_clear , -.Fn archive_entry_acl_add_entry , -.Fn archive_entry_acl_add_entry_w +.Fn archive_entry_acl_to_text_w +convert the ACL entries for the given type into a +.Pq wide +string of ACL entries separated by newline. If the the pointer +.Fa len_p +is not NULL, then the function shall return the length of the string +.Pq not including the NULL terminator +in the location pointed to by +.Fa len_p . +The +.Fa flag +argument is a bitwise-or. +.Pp +The following flags are effective only on POSIX.1e ACL: +.Bl -tag -offset indent -compact -width ARCHIV +.It Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS +Output access ACLs. +.It Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT +Output POSIX.1e default ACLs. +.It Dv ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT +Prefix each default ACL entry with the word +.Dq default: . +.It Dv ARCHIVE_ENTRY_ACL_STYLE_SOLARIS +The mask and other ACLs don not contain a double colon. +.El +.Pp +The following flags are effective on both POSIX.1e and NFSv4 ACL: +.Bl -tag -offset indent -compact -width ARCHIV +.It Dv ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID +Add an additional colon-separated field containing the user or group id. +.It Dv ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA +Separate ACL entries with comma instead of newline. +.El +.Pp +If the archive entry contains NFSv4 ACLs, all types of NFSv4 ACLs are returned. +It the entry contains POSIX.1e ACLs and none of the flags +.Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS or -.Fn archive_entry_acl_text_w . +.Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT +are specified, both access and default entries are returned and default entries +are prefixed with +.Dq default: . .Pp .Fn archive_entry_acl_types get ACL entry types contained in an archive entry's ACL. As POSIX.1e and NFSv4 @@ -205,11 +416,20 @@ an ACL already contains POSIX.1e or NFSv4 ACL entries. and .Fn archive_entry_acl_reset returns the number of ACL entries that match the given type mask. -If the type mask includes +For POSIX.1e ACLS if the type mask includes .Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS and at least one extended ACL entry exists, the three classic Unix permissions are counted. .Pp +.Fn archive_entry_acl_from_text +and +.Fn archive_entry_acl_from_text_w +return +.Dv ARCHIVE_OK +if all entries were successfully parsed and +.Dv ARCHIVE_WARN +if one or more entries were invalid or non-parseable. +.Pp .Fn archive_entry_acl_next and .Fn archive_entry_acl_next_w @@ -224,23 +444,16 @@ if .Fn archive_entry_acl_reset has not been called first. .Pp -.Fn archive_entry_text_w -returns a wide string representation of the ACL entrise matching the -given type mask. -The returned long string is valid until the next call to -.Fn archive_entry_acl_clear , -.Fn archive_entry_acl_add_entry , -.Fn archive_entry_acl_add_entry_w -or -.Fn archive_entry_acl_text_w . +.Fn archive_entry_acl_to_text +returns a string representing the ACL entries matching the given type and +flags on success or NULL on error. +.Pp +.Fn archive_entry_acl_to_text_w +returns a wide string representing the ACL entries matching the given type +and flags on success or NULL on error. .Pp .Fn archive_entry_acl_types returns a bitmask of ACL entry types or 0 if archive entry has no ACL entries. .Sh SEE ALSO -.Xr archive_entry 3 -.Xr libarchive 3 , -.Sh BUGS -.Dv ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID -and -.Dv ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT -are not documented. +.Xr archive_entry 3 , +.Xr libarchive 3 diff --git a/contrib/libarchive/libarchive/archive_entry_locale.h b/contrib/libarchive/libarchive/archive_entry_locale.h index 02e024a..44550c5 100644 --- a/contrib/libarchive/libarchive/archive_entry_locale.h +++ b/contrib/libarchive/libarchive/archive_entry_locale.h @@ -63,9 +63,13 @@ int _archive_entry_uname_l(struct archive_entry *, const char **, size_t *, struct archive_string_conv *); #define archive_entry_acl_text_l _archive_entry_acl_text_l int _archive_entry_acl_text_l(struct archive_entry *, int, - const char **, size_t *, struct archive_string_conv *); - - +const char **, size_t *, struct archive_string_conv *) __LA_DEPRECATED; +#define archive_entry_acl_to_text_l _archive_entry_acl_to_text_l +char *_archive_entry_acl_to_text_l(struct archive_entry *, ssize_t *, int, + struct archive_string_conv *); +#define archive_entry_acl_from_text_l _archive_entry_acl_from_text_l +int _archive_entry_acl_from_text_l(struct archive_entry *, const char* text, + int type, struct archive_string_conv *); #define archive_entry_copy_gname_l _archive_entry_copy_gname_l int _archive_entry_copy_gname_l(struct archive_entry *, const char *, size_t, struct archive_string_conv *); diff --git a/contrib/libarchive/libarchive/archive_entry_strmode.c b/contrib/libarchive/libarchive/archive_entry_strmode.c index 8d7006a..d80a7d4 100644 --- a/contrib/libarchive/libarchive/archive_entry_strmode.c +++ b/contrib/libarchive/libarchive/archive_entry_strmode.c @@ -80,7 +80,7 @@ archive_entry_strmode(struct archive_entry *entry) if (mode & 0001) bp[9] = 't'; else bp[9] = 'T'; } - if (archive_entry_acl_count(entry, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)) + if (archive_entry_acl_types(entry) != 0) bp[10] = '+'; return (bp); diff --git a/contrib/libarchive/libarchive/archive_match.c b/contrib/libarchive/libarchive/archive_match.c index 0719cbd..be72066 100644 --- a/contrib/libarchive/libarchive/archive_match.c +++ b/contrib/libarchive/libarchive/archive_match.c @@ -471,7 +471,7 @@ archive_match_path_excluded(struct archive *_a, } /* - * Utilty functions to get statistic information for inclusion patterns. + * Utility functions to get statistic information for inclusion patterns. */ int archive_match_path_unmatched_inclusions(struct archive *_a) @@ -1270,7 +1270,7 @@ set_timefilter_pathname_wcs(struct archive_match *a, int timetype, #endif /* _WIN32 && !__CYGWIN__ */ /* - * Call back funtions for archive_rb. + * Call back functions for archive_rb. */ static int cmp_node_mbs(const struct archive_rb_node *n1, @@ -1405,7 +1405,7 @@ add_entry(struct archive_match *a, int flag, &(a->exclusion_tree), pathname); /* - * We always overwrite comparison condision. + * We always overwrite comparison condition. * If you do not want to overwrite it, you should not * call archive_match_exclude_entry(). We cannot know * what behavior you really expect since overwriting @@ -1481,7 +1481,7 @@ time_excluded(struct archive_match *a, struct archive_entry *entry) if (nsec == a->older_ctime_nsec && (a->older_ctime_filter & ARCHIVE_MATCH_EQUAL) == 0) - return (1); /* Eeual, skip it. */ + return (1); /* Equal, skip it. */ } } if (a->newer_mtime_filter) { @@ -1513,7 +1513,7 @@ time_excluded(struct archive_match *a, struct archive_entry *entry) } } - /* If there is no excluson list, include the file. */ + /* If there is no exclusion list, include the file. */ if (a->exclusion_entry_list.count == 0) return (0); @@ -1700,7 +1700,7 @@ add_owner_id(struct archive_match *a, struct id_array *ids, int64_t id) break; } - /* Add oowner id. */ + /* Add owner id. */ if (i == ids->count) ids->ids[ids->count++] = id; else if (ids->ids[i] != id) { diff --git a/contrib/libarchive/libarchive/archive_platform.h b/contrib/libarchive/libarchive/archive_platform.h index 76816c4..31383db 100644 --- a/contrib/libarchive/libarchive/archive_platform.h +++ b/contrib/libarchive/libarchive/archive_platform.h @@ -147,8 +147,25 @@ * acl_set_file(), and ACL_USER, we assume it has the rest of the * POSIX.1e draft functions used in archive_read_extract.c. */ -#if HAVE_SYS_ACL_H && HAVE_ACL_CREATE_ENTRY && HAVE_ACL_INIT && HAVE_ACL_SET_FILE && HAVE_ACL_USER +#if HAVE_SYS_ACL_H && HAVE_ACL_CREATE_ENTRY && HAVE_ACL_INIT && HAVE_ACL_SET_FILE +#if HAVE_ACL_USER #define HAVE_POSIX_ACL 1 +#elif HAVE_ACL_TYPE_EXTENDED +#define HAVE_DARWIN_ACL 1 +#endif +#endif + +/* + * If this platform has , acl_get(), facl_get(), acl_set(), + * facl_set() and types aclent_t and ace_t it uses Solaris-style ACL functions + */ +#if HAVE_SYS_ACL_H && HAVE_ACL_GET && HAVE_FACL_GET && HAVE_ACL_SET && HAVE_FACL_SET && HAVE_ACLENT_T && HAVE_ACE_T +#define HAVE_SUN_ACL 1 +#endif + +/* Define if platform supports NFSv4 ACLs */ +#if (HAVE_POSIX_ACL && HAVE_ACL_TYPE_NFS4) || HAVE_SUN_ACL || HAVE_DARWIN_ACL +#define HAVE_NFS4_ACL 1 #endif /* diff --git a/contrib/libarchive/libarchive/archive_random.c b/contrib/libarchive/libarchive/archive_random.c index a20b9b1..357f973 100644 --- a/contrib/libarchive/libarchive/archive_random.c +++ b/contrib/libarchive/libarchive/archive_random.c @@ -80,7 +80,7 @@ archive_random(void *buf, size_t nbytes) success = CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); - if (!success && GetLastError() == NTE_BAD_KEYSET) { + if (!success && GetLastError() == (DWORD)NTE_BAD_KEYSET) { success = CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); } diff --git a/contrib/libarchive/libarchive/archive_rb.c b/contrib/libarchive/libarchive/archive_rb.c index 5b5da20..cf58ac3 100644 --- a/contrib/libarchive/libarchive/archive_rb.c +++ b/contrib/libarchive/libarchive/archive_rb.c @@ -312,7 +312,7 @@ __archive_rb_tree_insert_rebalance(struct archive_rb_tree *rbt, father = RB_FATHER(self); if (RB_BLACK_P(father)) { /* - * If our greatgrandpa is black, we're done. + * If our great-grandpa is black, we're done. */ return; } diff --git a/contrib/libarchive/libarchive/archive_read_disk.3 b/contrib/libarchive/libarchive/archive_read_disk.3 index 525dc59..2a5c130 100644 --- a/contrib/libarchive/libarchive/archive_read_disk.3 +++ b/contrib/libarchive/libarchive/archive_read_disk.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 2, 2012 +.Dd December 30, 2016 .Dt ARCHIVE_READ_DISK 3 .Os .Sh NAME @@ -54,9 +54,9 @@ Streaming Archive Library (libarchive, -larchive) .Fn archive_read_disk_set_symlink_physical "struct archive *" .Ft int .Fn archive_read_disk_set_symlink_hybrid "struct archive *" -.Ft int +.Ft const char * .Fn archive_read_disk_gname "struct archive *" "gid_t" -.Ft int +.Ft const char * .Fn archive_read_disk_uname "struct archive *" "uid_t" .Ft int .Fo archive_read_disk_set_gname_lookup diff --git a/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c b/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c index e9fb8ba..63aa617 100644 --- a/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c +++ b/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c @@ -1,6 +1,7 @@ /*- * Copyright (c) 2003-2009 Tim Kientzle * Copyright (c) 2010-2012 Michihiro NAKAJIMA + * Copyright (c) 2016 Martin Matuska * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,6 +38,11 @@ __FBSDID("$FreeBSD$"); #ifdef HAVE_SYS_ACL_H #include #endif +#ifdef HAVE_DARWIN_ACL +#include +#include +#include +#endif #ifdef HAVE_SYS_EXTATTR_H #include #endif @@ -117,6 +123,15 @@ __FBSDID("$FreeBSD$"); #define ACL_GET_PERM acl_get_perm_np #endif +/* NFSv4 platform ACL type */ +#if HAVE_SUN_ACL +#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACE_T +#elif HAVE_DARWIN_ACL +#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACL_TYPE_EXTENDED +#elif HAVE_ACL_TYPE_NFS4 +#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACL_TYPE_NFS4 +#endif + static int setup_acls(struct archive_read_disk *, struct archive_entry *, int *fd); static int setup_mac_metadata(struct archive_read_disk *, @@ -404,17 +419,38 @@ setup_mac_metadata(struct archive_read_disk *a, } #endif +#if HAVE_DARWIN_ACL +static int translate_guid(struct archive *, acl_entry_t, + int *, int *, const char **); + +static void add_trivial_nfs4_acl(struct archive_entry *); +#endif -#ifdef HAVE_POSIX_ACL +#if HAVE_SUN_ACL +static int +sun_acl_is_trivial(acl_t *, mode_t, int *trivialp); +#endif + +#if HAVE_POSIX_ACL || HAVE_NFS4_ACL static int translate_acl(struct archive_read_disk *a, - struct archive_entry *entry, acl_t acl, int archive_entry_acl_type); + struct archive_entry *entry, +#if HAVE_SUN_ACL + acl_t *acl, +#else + acl_t acl, +#endif + int archive_entry_acl_type); static int setup_acls(struct archive_read_disk *a, struct archive_entry *entry, int *fd) { const char *accpath; - acl_t acl; +#if HAVE_SUN_ACL + acl_t *acl; +#else + acl_t acl; +#endif int r; accpath = archive_entry_sourcepath(entry); @@ -439,17 +475,20 @@ setup_acls(struct archive_read_disk *a, acl = NULL; -#ifdef ACL_TYPE_NFS4 - /* Try NFS4 ACL first. */ +#if HAVE_NFS4_ACL + /* Try NFSv4 ACL first. */ if (*fd >= 0) -#if HAVE_ACL_GET_FD_NP - acl = acl_get_fd_np(*fd, ACL_TYPE_NFS4); +#if HAVE_SUN_ACL + /* Solaris reads both POSIX.1e and NFSv4 ACL here */ + facl_get(*fd, 0, &acl); +#elif HAVE_ACL_GET_FD_NP + acl = acl_get_fd_np(*fd, ARCHIVE_PLATFORM_ACL_TYPE_NFS4); #else acl = acl_get_fd(*fd); #endif #if HAVE_ACL_GET_LINK_NP else if (!a->follow_symlinks) - acl = acl_get_link_np(accpath, ACL_TYPE_NFS4); + acl = acl_get_link_np(accpath, ARCHIVE_PLATFORM_ACL_TYPE_NFS4); #else else if ((!a->follow_symlinks) && (archive_entry_filetype(entry) == AE_IFLNK)) @@ -458,12 +497,24 @@ setup_acls(struct archive_read_disk *a, acl = NULL; #endif else - acl = acl_get_file(accpath, ACL_TYPE_NFS4); +#if HAVE_SUN_ACL + /* Solaris reads both POSIX.1e and NFSv4 ACLs here */ + acl_get(accpath, 0, &acl); +#else + acl = acl_get_file(accpath, ARCHIVE_PLATFORM_ACL_TYPE_NFS4); +#endif -#if HAVE_ACL_IS_TRIVIAL_NP - if (acl != NULL && acl_is_trivial_np(acl, &r) == 0) { - /* Ignore "trivial" ACLs that just mirror the file mode. */ - if (r) { + +#if HAVE_ACL_IS_TRIVIAL_NP || HAVE_SUN_ACL + /* Ignore "trivial" ACLs that just mirror the file mode. */ + if (acl != NULL) { +#if HAVE_SUN_ACL + if (sun_acl_is_trivial(acl, archive_entry_mode(entry), + &r) == 0 && r == 1) +#elif HAVE_ACL_IS_TRIVIAL_NP + if (acl_is_trivial_np(acl, &r) == 0 && r == 1) +#endif + { acl_free(acl); acl = NULL; /* @@ -473,17 +524,35 @@ setup_acls(struct archive_read_disk *a, return (ARCHIVE_OK); } } -#endif +#endif /* HAVE_ACL_IS_TRIVIAL_NP || HAVE_SUN_ACL */ if (acl != NULL) { r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4); acl_free(acl); if (r != ARCHIVE_OK) { archive_set_error(&a->archive, errno, +#if HAVE_SUN_ACL + "Couldn't translate ACLs: %s", accpath); +#else "Couldn't translate NFSv4 ACLs: %s", accpath); +#endif } +#if HAVE_DARWIN_ACL + /* + * Because Mac OS doesn't support owner@, group@ and everyone@ + * ACLs we need to add NFSv4 ACLs mirroring the file mode to + * the archive entry. Otherwise extraction on non-Mac platforms + * would lead to an invalid file mode. + */ + if (archive_entry_acl_count(entry, + ARCHIVE_ENTRY_ACL_TYPE_NFS4) > 0) + add_trivial_nfs4_acl(entry); +#endif return (r); } -#endif /* ACL_TYPE_NFS4 */ +#endif /* HAVE_NFS4_ACL */ + +#if HAVE_POSIX_ACL + /* This code path is skipped on MacOS and Solaris */ /* Retrieve access ACL from file. */ if (*fd >= 0) @@ -512,8 +581,7 @@ setup_acls(struct archive_read_disk *a, #endif if (acl != NULL) { - r = translate_acl(a, entry, acl, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS); + r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_ACCESS); acl_free(acl); acl = NULL; if (r != ARCHIVE_OK) { @@ -525,6 +593,11 @@ setup_acls(struct archive_read_disk *a, /* Only directories can have default ACLs. */ if (S_ISDIR(archive_entry_mode(entry))) { +#if HAVE_ACL_GET_FD_NP + if (*fd >= 0) + acl = acl_get_fd_np(*fd, ACL_TYPE_DEFAULT); + else +#endif acl = acl_get_file(accpath, ACL_TYPE_DEFAULT); if (acl != NULL) { r = translate_acl(a, entry, acl, @@ -538,68 +611,560 @@ setup_acls(struct archive_read_disk *a, } } } +#endif /* HAVE_POSIX_ACL */ return (ARCHIVE_OK); } /* - * Translate system ACL into libarchive internal structure. + * Translate system ACL permissions into libarchive internal structure */ - static struct { - int archive_perm; - int platform_perm; + int archive_perm; + int platform_perm; } acl_perm_map[] = { - {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE}, - {ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE}, - {ARCHIVE_ENTRY_ACL_READ, ACL_READ}, -#ifdef ACL_TYPE_NFS4 - {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA}, - {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY}, - {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA}, - {ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE}, - {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA}, - {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY}, - {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_NAMED_ATTRS}, - {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_NAMED_ATTRS}, - {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD}, - {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES}, - {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES}, - {ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE}, - {ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_ACL}, - {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_ACL}, - {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER}, - {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE} +#if HAVE_SUN_ACL /* Solaris NFSv4 ACL permissions */ + {ARCHIVE_ENTRY_ACL_EXECUTE, ACE_EXECUTE}, + {ARCHIVE_ENTRY_ACL_READ_DATA, ACE_READ_DATA}, + {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACE_LIST_DIRECTORY}, + {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACE_WRITE_DATA}, + {ARCHIVE_ENTRY_ACL_ADD_FILE, ACE_ADD_FILE}, + {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACE_APPEND_DATA}, + {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACE_ADD_SUBDIRECTORY}, + {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACE_READ_NAMED_ATTRS}, + {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACE_WRITE_NAMED_ATTRS}, + {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACE_DELETE_CHILD}, + {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACE_READ_ATTRIBUTES}, + {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACE_WRITE_ATTRIBUTES}, + {ARCHIVE_ENTRY_ACL_DELETE, ACE_DELETE}, + {ARCHIVE_ENTRY_ACL_READ_ACL, ACE_READ_ACL}, + {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACE_WRITE_ACL}, + {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACE_WRITE_OWNER}, + {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACE_SYNCHRONIZE} +#elif HAVE_DARWIN_ACL /* MacOS ACL permissions */ + {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA}, + {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY}, + {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA}, + {ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE}, + {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE}, + {ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE}, + {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA}, + {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY}, + {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD}, + {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES}, + {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES}, + {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_EXTATTRIBUTES}, + {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_EXTATTRIBUTES}, + {ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_SECURITY}, + {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_SECURITY}, + {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_CHANGE_OWNER}, + {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE} +#else /* POSIX.1e ACL permissions */ + {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE}, + {ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE}, + {ARCHIVE_ENTRY_ACL_READ, ACL_READ}, +#if HAVE_ACL_TYPE_NFS4 /* FreeBSD NFSv4 ACL permissions */ + {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA}, + {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY}, + {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA}, + {ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE}, + {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA}, + {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY}, + {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_NAMED_ATTRS}, + {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_NAMED_ATTRS}, + {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD}, + {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES}, + {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES}, + {ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE}, + {ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_ACL}, + {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_ACL}, + {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER}, + {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE} #endif +#endif /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */ }; -#ifdef ACL_TYPE_NFS4 +#if HAVE_NFS4_ACL +/* + * Translate system NFSv4 inheritance flags into libarchive internal structure + */ static struct { - int archive_inherit; - int platform_inherit; + int archive_inherit; + int platform_inherit; } acl_inherit_map[] = { - {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT}, +#if HAVE_SUN_ACL /* Solaris ACL inheritance flags */ + {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACE_FILE_INHERIT_ACE}, + {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACE_DIRECTORY_INHERIT_ACE}, + {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACE_NO_PROPAGATE_INHERIT_ACE}, + {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACE_INHERIT_ONLY_ACE}, + {ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACE_SUCCESSFUL_ACCESS_ACE_FLAG}, + {ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACE_FAILED_ACCESS_ACE_FLAG}, + {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACE_INHERITED_ACE} +#elif HAVE_DARWIN_ACL /* MacOS NFSv4 inheritance flags */ + {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED}, + {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT}, + {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT}, + {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_LIMIT_INHERIT}, + {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_ONLY_INHERIT} +#else /* FreeBSD NFSv4 ACL inheritance flags */ + {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT}, {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT}, {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_NO_PROPAGATE_INHERIT}, - {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY} + {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY}, + {ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACL_ENTRY_SUCCESSFUL_ACCESS}, + {ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACL_ENTRY_FAILED_ACCESS}, + {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED} +#endif /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */ }; -#endif +#endif /* HAVE_NFS4_ACL */ + +#if HAVE_DARWIN_ACL +static int translate_guid(struct archive *a, acl_entry_t acl_entry, + int *ae_id, int *ae_tag, const char **ae_name) +{ + void *q; + uid_t ugid; + int r, idtype; + struct passwd *pwd; + struct group *grp; + + q = acl_get_qualifier(acl_entry); + if (q == NULL) + return (1); + r = mbr_uuid_to_id((const unsigned char *)q, &ugid, &idtype); + if (r != 0) { + acl_free(q); + return (1); + } + if (idtype == ID_TYPE_UID) { + *ae_tag = ARCHIVE_ENTRY_ACL_USER; + pwd = getpwuuid(q); + if (pwd == NULL) { + *ae_id = ugid; + *ae_name = NULL; + } else { + *ae_id = pwd->pw_uid; + *ae_name = archive_read_disk_uname(a, *ae_id); + } + } else if (idtype == ID_TYPE_GID) { + *ae_tag = ARCHIVE_ENTRY_ACL_GROUP; + grp = getgruuid(q); + if (grp == NULL) { + *ae_id = ugid; + *ae_name = NULL; + } else { + *ae_id = grp->gr_gid; + *ae_name = archive_read_disk_gname(a, *ae_id); + } + } else + r = 1; + + acl_free(q); + return (r); +} + +/* + * Add trivial NFSv4 ACL entries from mode + */ +static void +add_trivial_nfs4_acl(struct archive_entry *entry) +{ + mode_t mode; + int i; + const int rperm = ARCHIVE_ENTRY_ACL_READ_DATA; + const int wperm = ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA; + const int eperm = ARCHIVE_ENTRY_ACL_EXECUTE; + const int pubset = ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE; + const int ownset = pubset | ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_WRITE_ACL | + ARCHIVE_ENTRY_ACL_WRITE_OWNER; + + struct { + const int type; + const int tag; + int permset; + } tacl_entry[] = { + {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_USER_OBJ, 0}, + {ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_USER_OBJ, 0}, + {ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0}, + {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_USER_OBJ, ownset}, + {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_GROUP_OBJ, pubset}, + {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EVERYONE, pubset} + }; + + mode = archive_entry_mode(entry); + + /* Permissions for everyone@ */ + if (mode & 0004) + tacl_entry[5].permset |= rperm; + if (mode & 0002) + tacl_entry[5].permset |= wperm; + if (mode & 0001) + tacl_entry[5].permset |= eperm; + + /* Permissions for group@ */ + if (mode & 0040) + tacl_entry[4].permset |= rperm; + else if (mode & 0004) + tacl_entry[2].permset |= rperm; + if (mode & 0020) + tacl_entry[4].permset |= wperm; + else if (mode & 0002) + tacl_entry[2].permset |= wperm; + if (mode & 0010) + tacl_entry[4].permset |= eperm; + else if (mode & 0001) + tacl_entry[2].permset |= eperm; + + /* Permissions for owner@ */ + if (mode & 0400) { + tacl_entry[3].permset |= rperm; + if (!(mode & 0040) && (mode & 0004)) + tacl_entry[0].permset |= rperm; + } else if ((mode & 0040) || (mode & 0004)) + tacl_entry[1].permset |= rperm; + if (mode & 0200) { + tacl_entry[3].permset |= wperm; + if (!(mode & 0020) && (mode & 0002)) + tacl_entry[0].permset |= wperm; + } else if ((mode & 0020) || (mode & 0002)) + tacl_entry[1].permset |= wperm; + if (mode & 0100) { + tacl_entry[3].permset |= eperm; + if (!(mode & 0010) && (mode & 0001)) + tacl_entry[0].permset |= eperm; + } else if ((mode & 0010) || (mode & 0001)) + tacl_entry[1].permset |= eperm; + + for (i = 0; i < 6; i++) { + if (tacl_entry[i].permset != 0) { + archive_entry_acl_add_entry(entry, + tacl_entry[i].type, tacl_entry[i].permset, + tacl_entry[i].tag, -1, NULL); + } + } + + return; +} +#elif HAVE_SUN_ACL +/* + * Check if acl is trivial + * This is a FreeBSD acl_is_trivial_np() implementation for Solaris + */ +static int +sun_acl_is_trivial(acl_t *acl, mode_t mode, int *trivialp) +{ + int i, p; + const uint32_t rperm = ACE_READ_DATA; + const uint32_t wperm = ACE_WRITE_DATA | ACE_APPEND_DATA; + const uint32_t eperm = ACE_EXECUTE; + const uint32_t pubset = ACE_READ_ATTRIBUTES | ACE_READ_NAMED_ATTRS | + ACE_READ_ACL | ACE_SYNCHRONIZE; + const uint32_t ownset = pubset | ACE_WRITE_ATTRIBUTES | + ACE_WRITE_NAMED_ATTRS | ACE_WRITE_ACL | ACE_WRITE_OWNER; + + ace_t *ace; + ace_t tace[6]; + + if (acl == NULL || trivialp == NULL) + return (-1); + + *trivialp = 0; + + /* ACL_IS_TRIVIAL flag must be set for both POSIX.1e and NFSv4 ACLs */ + if ((acl->acl_flags & ACL_IS_TRIVIAL) == 0) + return (0); + + /* + * POSIX.1e ACLs marked with ACL_IS_TRIVIAL are compatible with + * FreeBSD acl_is_trivial_np(). On Solaris they have 4 entries, + * incuding mask. + */ + if (acl->acl_type == ACLENT_T) { + if (acl->acl_cnt == 4) + *trivialp = 1; + return (0); + } + + if (acl->acl_type != ACE_T || acl->acl_entry_size != sizeof(ace_t)) + return (-1); + + /* + * Continue with checking NFSv4 ACLs + * + * Create list of trivial ace's to be compared + */ + + /* owner@ allow pre */ + tace[0].a_flags = ACE_OWNER; + tace[0].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE; + tace[0].a_access_mask = 0; + + /* owner@ deny */ + tace[1].a_flags = ACE_OWNER; + tace[1].a_type = ACE_ACCESS_DENIED_ACE_TYPE; + tace[1].a_access_mask = 0; + + /* group@ deny */ + tace[2].a_flags = ACE_GROUP | ACE_IDENTIFIER_GROUP; + tace[2].a_type = ACE_ACCESS_DENIED_ACE_TYPE; + tace[2].a_access_mask = 0; + + /* owner@ allow */ + tace[3].a_flags = ACE_OWNER; + tace[3].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE; + tace[3].a_access_mask = ownset; + + /* group@ allow */ + tace[4].a_flags = ACE_GROUP | ACE_IDENTIFIER_GROUP; + tace[4].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE; + tace[4].a_access_mask = pubset; + + /* everyone@ allow */ + tace[5].a_flags = ACE_EVERYONE; + tace[5].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE; + tace[5].a_access_mask = pubset; + + /* Permissions for everyone@ */ + if (mode & 0004) + tace[5].a_access_mask |= rperm; + if (mode & 0002) + tace[5].a_access_mask |= wperm; + if (mode & 0001) + tace[5].a_access_mask |= eperm; + + /* Permissions for group@ */ + if (mode & 0040) + tace[4].a_access_mask |= rperm; + else if (mode & 0004) + tace[2].a_access_mask |= rperm; + if (mode & 0020) + tace[4].a_access_mask |= wperm; + else if (mode & 0002) + tace[2].a_access_mask |= wperm; + if (mode & 0010) + tace[4].a_access_mask |= eperm; + else if (mode & 0001) + tace[2].a_access_mask |= eperm; + + /* Permissions for owner@ */ + if (mode & 0400) { + tace[3].a_access_mask |= rperm; + if (!(mode & 0040) && (mode & 0004)) + tace[0].a_access_mask |= rperm; + } else if ((mode & 0040) || (mode & 0004)) + tace[1].a_access_mask |= rperm; + if (mode & 0200) { + tace[3].a_access_mask |= wperm; + if (!(mode & 0020) && (mode & 0002)) + tace[0].a_access_mask |= wperm; + } else if ((mode & 0020) || (mode & 0002)) + tace[1].a_access_mask |= wperm; + if (mode & 0100) { + tace[3].a_access_mask |= eperm; + if (!(mode & 0010) && (mode & 0001)) + tace[0].a_access_mask |= eperm; + } else if ((mode & 0010) || (mode & 0001)) + tace[1].a_access_mask |= eperm; + + /* Check if the acl count matches */ + p = 3; + for (i = 0; i < 3; i++) { + if (tace[i].a_access_mask != 0) + p++; + } + if (acl->acl_cnt != p) + return (0); + + p = 0; + for (i = 0; i < 6; i++) { + if (tace[i].a_access_mask != 0) { + ace = &((ace_t *)acl->acl_aclp)[p]; + /* + * Illumos added ACE_DELETE_CHILD to write perms for + * directories. We have to check against that, too. + */ + if (ace->a_flags != tace[i].a_flags || + ace->a_type != tace[i].a_type || + (ace->a_access_mask != tace[i].a_access_mask && + ((acl->acl_flags & ACL_IS_DIR) == 0 || + (tace[i].a_access_mask & wperm) == 0 || + ace->a_access_mask != + (tace[i].a_access_mask | ACE_DELETE_CHILD)))) + return (0); + p++; + } + } + + *trivialp = 1; + return (0); +} +#endif /* HAVE_SUN_ACL */ + +#if HAVE_SUN_ACL +/* + * Translate Solaris POSIX.1e and NFSv4 ACLs into libarchive internal ACL + */ +static int +translate_acl(struct archive_read_disk *a, + struct archive_entry *entry, acl_t *acl, int default_entry_acl_type) +{ + int e, i; + int ae_id, ae_tag, ae_perm; + int entry_acl_type; + const char *ae_name; + aclent_t *aclent; + ace_t *ace; + + (void)default_entry_acl_type; + + if (acl->acl_cnt <= 0) + return (ARCHIVE_OK); + + for (e = 0; e < acl->acl_cnt; e++) { + ae_name = NULL; + ae_tag = 0; + ae_perm = 0; + + if (acl->acl_type == ACE_T) { + ace = &((ace_t *)acl->acl_aclp)[e]; + ae_id = ace->a_who; + + switch(ace->a_type) { + case ACE_ACCESS_ALLOWED_ACE_TYPE: + entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW; + break; + case ACE_ACCESS_DENIED_ACE_TYPE: + entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY; + break; + case ACE_SYSTEM_AUDIT_ACE_TYPE: + entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS; + break; + case ACE_SYSTEM_ALARM_ACE_TYPE: + entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALARM; + break; + default: + /* Unknown entry type, skip */ + continue; + } + + if ((ace->a_flags & ACE_OWNER) != 0) + ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ; + else if ((ace->a_flags & ACE_GROUP) != 0) + ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ; + else if ((ace->a_flags & ACE_EVERYONE) != 0) + ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE; + else if ((ace->a_flags & ACE_IDENTIFIER_GROUP) != 0) { + ae_tag = ARCHIVE_ENTRY_ACL_GROUP; + ae_name = archive_read_disk_gname(&a->archive, + ae_id); + } else { + ae_tag = ARCHIVE_ENTRY_ACL_USER; + ae_name = archive_read_disk_uname(&a->archive, + ae_id); + } + + for (i = 0; i < (int)(sizeof(acl_inherit_map) / + sizeof(acl_inherit_map[0])); ++i) { + if ((ace->a_flags & + acl_inherit_map[i].platform_inherit) != 0) + ae_perm |= + acl_inherit_map[i].archive_inherit; + } + + for (i = 0; i < (int)(sizeof(acl_perm_map) / + sizeof(acl_perm_map[0])); ++i) { + if ((ace->a_access_mask & + acl_perm_map[i].platform_perm) != 0) + ae_perm |= + acl_perm_map[i].archive_perm; + } + } else { + aclent = &((aclent_t *)acl->acl_aclp)[e]; + if ((aclent->a_type & ACL_DEFAULT) != 0) + entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT; + else + entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS; + ae_id = aclent->a_id; + + switch(aclent->a_type) { + case DEF_USER: + case USER: + ae_name = archive_read_disk_uname(&a->archive, + ae_id); + ae_tag = ARCHIVE_ENTRY_ACL_USER; + break; + case DEF_GROUP: + case GROUP: + ae_name = archive_read_disk_gname(&a->archive, + ae_id); + ae_tag = ARCHIVE_ENTRY_ACL_GROUP; + break; + case DEF_CLASS_OBJ: + case CLASS_OBJ: + ae_tag = ARCHIVE_ENTRY_ACL_MASK; + break; + case DEF_USER_OBJ: + case USER_OBJ: + ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ; + break; + case DEF_GROUP_OBJ: + case GROUP_OBJ: + ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ; + break; + case DEF_OTHER_OBJ: + case OTHER_OBJ: + ae_tag = ARCHIVE_ENTRY_ACL_OTHER; + break; + default: + /* Unknown tag type, skip */ + continue; + } + + if ((aclent->a_perm & 1) != 0) + ae_perm |= ARCHIVE_ENTRY_ACL_EXECUTE; + if ((aclent->a_perm & 2) != 0) + ae_perm |= ARCHIVE_ENTRY_ACL_WRITE; + if ((aclent->a_perm & 4) != 0) + ae_perm |= ARCHIVE_ENTRY_ACL_READ; + } /* default_entry_acl_type != ARCHIVE_ENTRY_ACL_TYPE_NFS4 */ + + archive_entry_acl_add_entry(entry, entry_acl_type, + ae_perm, ae_tag, ae_id, ae_name); + } + return (ARCHIVE_OK); +} +#else /* !HAVE_SUN_ACL */ +/* + * Translate POSIX.1e (Linux), FreeBSD (both POSIX.1e and NFSv4) and + * MacOS (NFSv4 only) ACLs into libarchive internal structure + */ static int translate_acl(struct archive_read_disk *a, struct archive_entry *entry, acl_t acl, int default_entry_acl_type) { acl_tag_t acl_tag; -#ifdef ACL_TYPE_NFS4 +#if HAVE_ACL_TYPE_NFS4 acl_entry_type_t acl_type; - acl_flagset_t acl_flagset; int brand; #endif +#if HAVE_ACL_TYPE_NFS4 || HAVE_DARWIN_ACL + acl_flagset_t acl_flagset; +#endif acl_entry_t acl_entry; acl_permset_t acl_permset; int i, entry_acl_type; int r, s, ae_id, ae_tag, ae_perm; +#if !HAVE_DARWIN_ACL + void *q; +#endif const char *ae_name; -#ifdef ACL_TYPE_NFS4 +#if HAVE_ACL_TYPE_NFS4 // FreeBSD "brands" ACLs as POSIX.1e or NFSv4 // Make sure the "brand" on this ACL is consistent // with the default_entry_acl_type bits provided. @@ -634,14 +1199,19 @@ translate_acl(struct archive_read_disk *a, } #endif - s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry); if (s == -1) { archive_set_error(&a->archive, errno, "Failed to get first ACL entry"); return (ARCHIVE_WARN); } - while (s == 1) { + +#if HAVE_DARWIN_ACL + while (s == 0) +#else /* FreeBSD, Linux */ + while (s == 1) +#endif + { ae_id = -1; ae_name = NULL; ae_perm = 0; @@ -652,14 +1222,25 @@ translate_acl(struct archive_read_disk *a, return (ARCHIVE_WARN); } switch (acl_tag) { +#if !HAVE_DARWIN_ACL /* FreeBSD, Linux */ case ACL_USER: - ae_id = (int)*(uid_t *)acl_get_qualifier(acl_entry); - ae_name = archive_read_disk_uname(&a->archive, ae_id); + q = acl_get_qualifier(acl_entry); + if (q != NULL) { + ae_id = (int)*(uid_t *)q; + acl_free(q); + ae_name = archive_read_disk_uname(&a->archive, + ae_id); + } ae_tag = ARCHIVE_ENTRY_ACL_USER; break; case ACL_GROUP: - ae_id = (int)*(gid_t *)acl_get_qualifier(acl_entry); - ae_name = archive_read_disk_gname(&a->archive, ae_id); + q = acl_get_qualifier(acl_entry); + if (q != NULL) { + ae_id = (int)*(gid_t *)q; + acl_free(q); + ae_name = archive_read_disk_gname(&a->archive, + ae_id); + } ae_tag = ARCHIVE_ENTRY_ACL_GROUP; break; case ACL_MASK: @@ -674,21 +1255,44 @@ translate_acl(struct archive_read_disk *a, case ACL_OTHER: ae_tag = ARCHIVE_ENTRY_ACL_OTHER; break; -#ifdef ACL_TYPE_NFS4 +#if HAVE_ACL_TYPE_NFS4 case ACL_EVERYONE: ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE; break; #endif +#else /* HAVE_DARWIN_ACL */ + case ACL_EXTENDED_ALLOW: + entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW; + r = translate_guid(&a->archive, acl_entry, &ae_id, + &ae_tag, &ae_name); + break; + case ACL_EXTENDED_DENY: + entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY; + r = translate_guid(&a->archive, acl_entry, &ae_id, + &ae_tag, &ae_name); + break; +#endif /* HAVE_DARWIN_ACL */ default: /* Skip types that libarchive can't support. */ s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry); continue; } +#if HAVE_DARWIN_ACL + /* Skip if translate_guid() above failed */ + if (r != 0) { + s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry); + continue; + } +#endif + +#if !HAVE_DARWIN_ACL // XXX acl_type maps to allow/deny/audit/YYYY bits entry_acl_type = default_entry_acl_type; -#ifdef ACL_TYPE_NFS4 +#endif +#if HAVE_ACL_TYPE_NFS4 || HAVE_DARWIN_ACL if (default_entry_acl_type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) { +#if HAVE_ACL_TYPE_NFS4 /* * acl_get_entry_type_np() fails with non-NFSv4 ACLs */ @@ -715,6 +1319,7 @@ translate_acl(struct archive_read_disk *a, "Invalid NFSv4 ACL entry type"); return (ARCHIVE_WARN); } +#endif /* HAVE_ACL_TYPE_NFS4 */ /* * Libarchive stores "flag" (NFSv4 inheritance bits) @@ -727,7 +1332,7 @@ translate_acl(struct archive_read_disk *a, "Failed to get flagset from a NFSv4 ACL entry"); return (ARCHIVE_WARN); } - for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) { + for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) { r = acl_get_flag_np(acl_flagset, acl_inherit_map[i].platform_inherit); if (r == -1) { @@ -737,9 +1342,9 @@ translate_acl(struct archive_read_disk *a, return (ARCHIVE_WARN); } else if (r) ae_perm |= acl_inherit_map[i].archive_inherit; - } + } } -#endif +#endif /* HAVE_ACL_TYPE_NFS4 || HAVE_DARWIN_ACL */ if (acl_get_permset(acl_entry, &acl_permset) != 0) { archive_set_error(&a->archive, errno, @@ -765,15 +1370,18 @@ translate_acl(struct archive_read_disk *a, ae_id, ae_name); s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry); +#if !HAVE_DARWIN_ACL if (s == -1) { archive_set_error(&a->archive, errno, "Failed to get next ACL entry"); return (ARCHIVE_WARN); } +#endif } return (ARCHIVE_OK); } -#else +#endif /* !HAVE_SUN_ACL */ +#else /* !HAVE_POSIX_ACL && !HAVE_NFS4_ACL */ static int setup_acls(struct archive_read_disk *a, struct archive_entry *entry, int *fd) @@ -783,7 +1391,7 @@ setup_acls(struct archive_read_disk *a, (void)fd; /* UNUSED */ return (ARCHIVE_OK); } -#endif +#endif /* !HAVE_POSIX_ACL && !HAVE_NFS4_ACL */ #if (HAVE_FGETXATTR && HAVE_FLISTXATTR && HAVE_LISTXATTR && \ HAVE_LLISTXATTR && HAVE_GETXATTR && HAVE_LGETXATTR) || \ diff --git a/contrib/libarchive/libarchive/archive_read_disk_posix.c b/contrib/libarchive/libarchive/archive_read_disk_posix.c index bc7fad1..b893704 100644 --- a/contrib/libarchive/libarchive/archive_read_disk_posix.c +++ b/contrib/libarchive/libarchive/archive_read_disk_posix.c @@ -675,7 +675,7 @@ setup_suitable_read_buffer(struct archive_read_disk *a) asize = cf->min_xfer_size; /* Increase a buffer size up to 64K bytes in - * a proper incremant size. */ + * a proper increment size. */ while (asize < 1024*64) asize += incr; /* Take a margin to adjust to the filesystem @@ -1656,7 +1656,7 @@ setup_current_filesystem(struct archive_read_disk *a) archive_set_error(&a->archive, errno, "statvfs failed"); return (ARCHIVE_FAILED); } else if (xr == 1) { - /* Usuall come here unless NetBSD supports _PC_REC_XFER_ALIGN + /* Usually come here unless NetBSD supports _PC_REC_XFER_ALIGN * for pathconf() function. */ t->current_filesystem->xfer_align = sfs.f_frsize; t->current_filesystem->max_xfer_size = -1; @@ -1944,7 +1944,7 @@ setup_current_filesystem(struct archive_read_disk *a) if (nm == -1) # endif /* _PC_NAME_MAX */ /* - * Some sysmtes (HP-UX or others?) incorrectly defined + * Some systems (HP-UX or others?) incorrectly defined * NAME_MAX macro to be a smaller value. */ # if defined(NAME_MAX) && NAME_MAX >= 255 diff --git a/contrib/libarchive/libarchive/archive_read_open_filename.c b/contrib/libarchive/libarchive/archive_read_open_filename.c index b2d52aa..64b0179 100644 --- a/contrib/libarchive/libarchive/archive_read_open_filename.c +++ b/contrib/libarchive/libarchive/archive_read_open_filename.c @@ -222,7 +222,7 @@ file_open(struct archive *a, void *client_data) void *buffer; const char *filename = NULL; const wchar_t *wfilename = NULL; - int fd; + int fd = -1; int is_disk_like = 0; #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) off_t mediasize = 0; /* FreeBSD-specific, so off_t okay here. */ @@ -277,7 +277,7 @@ file_open(struct archive *a, void *client_data) #else archive_set_error(a, ARCHIVE_ERRNO_MISC, "Unexpedted operation in archive_read_open_filename"); - return (ARCHIVE_FATAL); + goto fail; #endif } if (fstat(fd, &st) != 0) { @@ -287,7 +287,7 @@ file_open(struct archive *a, void *client_data) else archive_set_error(a, errno, "Can't stat '%s'", filename); - return (ARCHIVE_FATAL); + goto fail; } /* @@ -356,11 +356,9 @@ file_open(struct archive *a, void *client_data) mine->block_size = new_block_size; } buffer = malloc(mine->block_size); - if (mine == NULL || buffer == NULL) { + if (buffer == NULL) { archive_set_error(a, ENOMEM, "No memory"); - free(mine); - free(buffer); - return (ARCHIVE_FATAL); + goto fail; } mine->buffer = buffer; mine->fd = fd; @@ -372,6 +370,14 @@ file_open(struct archive *a, void *client_data) mine->use_lseek = 1; return (ARCHIVE_OK); +fail: + /* + * Don't close file descriptors not opened or ones pointing referring + * to `FNT_STDIN`. + */ + if (fd != -1 && fd != 0) + close(fd); + return (ARCHIVE_FATAL); } static ssize_t diff --git a/contrib/libarchive/libarchive/archive_read_support_filter_lz4.c b/contrib/libarchive/libarchive/archive_read_support_filter_lz4.c index 37b2f59..663e2d3 100644 --- a/contrib/libarchive/libarchive/archive_read_support_filter_lz4.c +++ b/contrib/libarchive/libarchive/archive_read_support_filter_lz4.c @@ -180,7 +180,7 @@ lz4_reader_bid(struct archive_read_filter_bidder *self, return (0); bits_checked += 8; BD = buffer[5]; - /* A block maximum size shuld be more than 3. */ + /* A block maximum size should be more than 3. */ if (((BD & 0x70) >> 4) < 4) return (0); /* Reserved bits must be "0". */ @@ -417,7 +417,7 @@ lz4_filter_read_descriptor(struct archive_read_filter *self) /* Reserved bits must be zero. */ if (bd & 0x8f) goto malformed_error; - /* Get a maxinum block size. */ + /* Get a maximum block size. */ switch (read_buf[1] >> 4) { case 4: /* 64 KB */ state->flags.block_maximum_size = 64 * 1024; @@ -627,7 +627,7 @@ lz4_filter_read_default_stream(struct archive_read_filter *self, const void **p) if (state->stage == SELECT_STREAM) { state->stage = READ_DEFAULT_STREAM; - /* First, read a desciprtor. */ + /* First, read a descriptor. */ if((ret = lz4_filter_read_descriptor(self)) != ARCHIVE_OK) return (ret); state->stage = READ_DEFAULT_BLOCK; @@ -706,6 +706,11 @@ lz4_filter_read_legacy_stream(struct archive_read_filter *self, const void **p) /* Make sure we have a whole block. */ read_buf = __archive_read_filter_ahead(self->upstream, 4 + compressed, NULL); + if (read_buf == NULL) { + archive_set_error(&(self->archive->archive), + ARCHIVE_ERRNO_MISC, "truncated lz4 input"); + return (ARCHIVE_FATAL); + } ret = LZ4_decompress_safe(read_buf + 4, state->out_block, compressed, (int)state->out_block_size); if (ret < 0) { diff --git a/contrib/libarchive/libarchive/archive_read_support_filter_lzop.c b/contrib/libarchive/libarchive/archive_read_support_filter_lzop.c index 44ac9964..a1c392f 100644 --- a/contrib/libarchive/libarchive/archive_read_support_filter_lzop.c +++ b/contrib/libarchive/libarchive/archive_read_support_filter_lzop.c @@ -436,7 +436,7 @@ lzop_filter_read(struct archive_read_filter *self, const void **p) } /* - * Drive lzo uncompresison. + * Drive lzo uncompression. */ out_size = (lzo_uint)state->uncompressed_size; r = lzo1x_decompress_safe(b, (lzo_uint)state->compressed_size, diff --git a/contrib/libarchive/libarchive/archive_read_support_filter_program.c b/contrib/libarchive/libarchive/archive_read_support_filter_program.c index 66dc2f4..b8bf128 100644 --- a/contrib/libarchive/libarchive/archive_read_support_filter_program.c +++ b/contrib/libarchive/libarchive/archive_read_support_filter_program.c @@ -430,6 +430,7 @@ __archive_read_program(struct archive_read_filter *self, const char *cmd) &state->child_stdout); if (child == -1) { free(state->out_buf); + archive_string_free(&state->description); free(state); archive_set_error(&self->archive->archive, EINVAL, "Can't initialize filter; unable to run program \"%s\"", @@ -441,6 +442,7 @@ __archive_read_program(struct archive_read_filter *self, const char *cmd) if (state->child == NULL) { child_stop(self, state); free(state->out_buf); + archive_string_free(&state->description); free(state); archive_set_error(&self->archive->archive, EINVAL, "Can't initialize filter; unable to run program \"%s\"", diff --git a/contrib/libarchive/libarchive/archive_read_support_format_7zip.c b/contrib/libarchive/libarchive/archive_read_support_format_7zip.c index f8d52fb..3387eaf 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_7zip.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_7zip.c @@ -552,7 +552,7 @@ skip_sfx(struct archive_read *a, ssize_t bytes_avail) /* * If bytes_avail > SFX_MIN_ADDR we do not have to call * __archive_read_seek() at this time since we have - * alredy had enough data. + * already had enough data. */ if (bytes_avail > SFX_MIN_ADDR) __archive_read_consume(a, SFX_MIN_ADDR); @@ -760,7 +760,7 @@ archive_read_format_7zip_read_header(struct archive_read *a, symsize += size; } if (symsize == 0) { - /* If there is no synname, handle it as a regular + /* If there is no symname, handle it as a regular * file. */ zip_entry->mode &= ~AE_IFMT; zip_entry->mode |= AE_IFREG; @@ -3288,7 +3288,7 @@ read_stream(struct archive_read *a, const void **buff, size_t size, return (r); /* - * Skip the bytes we alrady has skipped in skip_stream(). + * Skip the bytes we already has skipped in skip_stream(). */ while (skip_bytes) { ssize_t skipped; @@ -3506,7 +3506,7 @@ setup_decode_folder(struct archive_read *a, struct _7z_folder *folder, return (ARCHIVE_FATAL); } - /* Allocate memory for the decorded data of a sub + /* Allocate memory for the decoded data of a sub * stream. */ b[i] = malloc((size_t)zip->folder_outbytes_remaining); if (b[i] == NULL) { @@ -3591,7 +3591,7 @@ skip_stream(struct archive_read *a, size_t skip_bytes) if (zip->folder_index == 0) { /* * Optimization for a list mode. - * Avoid unncecessary decoding operations. + * Avoid unnecessary decoding operations. */ zip->si.ci.folders[zip->entry->folderIndex].skipped_bytes += skip_bytes; diff --git a/contrib/libarchive/libarchive/archive_read_support_format_cab.c b/contrib/libarchive/libarchive/archive_read_support_format_cab.c index 2bdc1e2..e2f8c6b 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_cab.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_cab.c @@ -1495,6 +1495,8 @@ cab_read_ahead_cfdata_deflate(struct archive_read *a, ssize_t *avail) /* Cut out a tow-byte MSZIP signature(0x43, 0x4b). */ if (mszip > 0) { + if (bytes_avail <= 0) + goto nomszip; if (bytes_avail <= mszip) { if (mszip == 2) { if (cab->stream.next_in[0] != 0x43) diff --git a/contrib/libarchive/libarchive/archive_read_support_format_cpio.c b/contrib/libarchive/libarchive/archive_read_support_format_cpio.c index 2a5a829..e19c711 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_cpio.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_cpio.c @@ -434,7 +434,8 @@ archive_read_format_cpio_read_header(struct archive_read *a, * header. XXX */ /* Compare name to "TRAILER!!!" to test for end-of-archive. */ - if (namelength == 11 && strcmp((const char *)h, "TRAILER!!!") == 0) { + if (namelength == 11 && memcmp((const char *)h, "TRAILER!!!", + 11) == 0) { /* TODO: Store file location of start of block. */ archive_clear_error(&a->archive); return (ARCHIVE_EOF); diff --git a/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c b/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c index 3807abd..ebbfc2f 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c @@ -322,7 +322,7 @@ struct iso9660 { struct archive_string pathname; char seenRockridge; /* Set true if RR extensions are used. */ - char seenSUSP; /* Set true if SUSP is beging used. */ + char seenSUSP; /* Set true if SUSP is being used. */ char seenJoliet; unsigned char suspOffset; @@ -374,7 +374,7 @@ struct iso9660 { size_t utf16be_path_len; unsigned char *utf16be_previous_path; size_t utf16be_previous_path_len; - /* Null buufer used in bidder to improve its performance. */ + /* Null buffer used in bidder to improve its performance. */ unsigned char null[2048]; }; @@ -1199,7 +1199,7 @@ archive_read_format_iso9660_read_header(struct archive_read *a, archive_string_conversion_from_charset( &(a->archive), "UTF-16BE", 1); if (iso9660->sconv_utf16be == NULL) - /* Coundn't allocate memory */ + /* Couldn't allocate memory */ return (ARCHIVE_FATAL); } if (iso9660->utf16be_path == NULL) { @@ -1864,7 +1864,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent, if ((file->utf16be_name = malloc(name_len)) == NULL) { archive_set_error(&a->archive, ENOMEM, "No memory for file name"); - return (NULL); + goto fail; } memcpy(file->utf16be_name, p, name_len); file->utf16be_bytes = name_len; @@ -1943,10 +1943,8 @@ parse_file_info(struct archive_read *a, struct file_info *parent, file->symlink_continues = 0; rr_start += iso9660->suspOffset; r = parse_rockridge(a, file, rr_start, rr_end); - if (r != ARCHIVE_OK) { - free(file); - return (NULL); - } + if (r != ARCHIVE_OK) + goto fail; /* * A file size of symbolic link files in ISO images * made by makefs is not zero and its location is @@ -1990,7 +1988,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent, archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Invalid Rockridge RE"); - return (NULL); + goto fail; } /* * Sanity check: file does not have "CL" extension. @@ -1999,7 +1997,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent, archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Invalid Rockridge RE and CL"); - return (NULL); + goto fail; } /* * Sanity check: The file type must be a directory. @@ -2008,7 +2006,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent, archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Invalid Rockridge RE"); - return (NULL); + goto fail; } } else if (parent != NULL && parent->rr_moved) file->rr_moved_has_re_only = 0; @@ -2022,7 +2020,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent, archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Invalid Rockridge CL"); - return (NULL); + goto fail; } /* * Sanity check: The file type must be a regular file. @@ -2031,7 +2029,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent, archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Invalid Rockridge CL"); - return (NULL); + goto fail; } parent->subdirs++; /* Overwrite an offset and a number of this "CL" entry @@ -2049,7 +2047,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent, archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Invalid Rockridge CL"); - return (NULL); + goto fail; } } if (file->cl_offset == file->offset || @@ -2057,7 +2055,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent, archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Invalid Rockridge CL"); - return (NULL); + goto fail; } } } @@ -2088,6 +2086,10 @@ parse_file_info(struct archive_read *a, struct file_info *parent, #endif register_file(iso9660, file); return (file); +fail: + archive_string_free(&file->name); + free(file); + return (NULL); } static int @@ -2407,7 +2409,7 @@ read_CE(struct archive_read *a, struct iso9660 *iso9660) return (ARCHIVE_FATAL); } while (heap->cnt && heap->reqs[0].offset == iso9660->current_position); - /* NOTE: Do not move this consume's code to fron of + /* NOTE: Do not move this consume's code to front of * do-while loop. Registration of nested CE extension * might cause error because of current position. */ __archive_read_consume(a, step); @@ -2729,7 +2731,7 @@ next_cache_entry(struct archive_read *a, struct iso9660 *iso9660, if (file == NULL) { /* * If directory entries all which are descendant of - * rr_moved are stil remaning, expose their. + * rr_moved are still remaining, expose their. */ if (iso9660->re_files.first != NULL && iso9660->rr_moved != NULL && @@ -2852,7 +2854,7 @@ next_cache_entry(struct archive_read *a, struct iso9660 *iso9660, empty_files.last = &empty_files.first; /* Collect files which has the same file serial number. * Peek pending_files so that file which number is different - * is not put bak. */ + * is not put back. */ while (iso9660->pending_files.used > 0 && (iso9660->pending_files.files[0]->number == -1 || iso9660->pending_files.files[0]->number == number)) { @@ -2860,7 +2862,7 @@ next_cache_entry(struct archive_read *a, struct iso9660 *iso9660, /* This file has the same offset * but it's wrong offset which empty files * and symlink files have. - * NOTE: This wrong offse was recorded by + * NOTE: This wrong offset was recorded by * old mkisofs utility. If ISO images is * created by latest mkisofs, this does not * happen. diff --git a/contrib/libarchive/libarchive/archive_read_support_format_lha.c b/contrib/libarchive/libarchive/archive_read_support_format_lha.c index a7f1d8d..d77a7c2 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_lha.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_lha.c @@ -924,6 +924,9 @@ lha_read_file_header_1(struct archive_read *a, struct lha *lha) /* Get a real compressed file size. */ lha->compsize -= extdsize - 2; + if (lha->compsize < 0) + goto invalid; /* Invalid compressed file size */ + if (sum_calculated != headersum) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "LHa header sum error"); @@ -1711,7 +1714,7 @@ lha_crc16(uint16_t crc, const void *pp, size_t len) */ for (;len >= 8; len -= 8) { /* This if statement expects compiler optimization will - * remove the stament which will not be executed. */ + * remove the statement which will not be executed. */ #undef bswap16 #if defined(_MSC_VER) && _MSC_VER >= 1400 /* Visual Studio */ # define bswap16(x) _byteswap_ushort(x) diff --git a/contrib/libarchive/libarchive/archive_read_support_format_mtree.c b/contrib/libarchive/libarchive/archive_read_support_format_mtree.c index 02c1251..179f161 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_mtree.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_mtree.c @@ -715,13 +715,13 @@ detect_form(struct archive_read *a, int *is_form_d) } } else break; - } else if (strncmp(p, "/set", 4) == 0) { + } else if (len > 4 && strncmp(p, "/set", 4) == 0) { if (bid_keyword_list(p+4, len-4, 0, 0) <= 0) break; /* This line continues. */ if (p[len-nl-1] == '\\') multiline = 2; - } else if (strncmp(p, "/unset", 6) == 0) { + } else if (len > 6 && strncmp(p, "/unset", 6) == 0) { if (bid_keyword_list(p+6, len-6, 1, 0) <= 0) break; /* This line continues. */ @@ -1019,11 +1019,11 @@ read_mtree(struct archive_read *a, struct mtree *mtree) if (*p != '/') { r = process_add_entry(a, mtree, &global, p, len, &last_entry, is_form_d); - } else if (strncmp(p, "/set", 4) == 0) { + } else if (len > 4 && strncmp(p, "/set", 4) == 0) { if (p[4] != ' ' && p[4] != '\t') break; r = process_global_set(a, &global, p); - } else if (strncmp(p, "/unset", 6) == 0) { + } else if (len > 6 && strncmp(p, "/unset", 6) == 0) { if (p[6] != ' ' && p[6] != '\t') break; r = process_global_unset(a, &global, p); diff --git a/contrib/libarchive/libarchive/archive_read_support_format_rar.c b/contrib/libarchive/libarchive/archive_read_support_format_rar.c index 9c9f6f1..1e9849f 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_rar.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_rar.c @@ -906,7 +906,7 @@ archive_read_format_rar_read_header(struct archive_read *a, sizeof(rar->reserved2)); } - /* Main header is password encrytped, so we cannot read any + /* Main header is password encrypted, so we cannot read any file names or any other info about files from the header. */ if (rar->main_flags & MHD_PASSWORD) { diff --git a/contrib/libarchive/libarchive/archive_read_support_format_tar.c b/contrib/libarchive/libarchive/archive_read_support_format_tar.c index 4f69c6e..446d005 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_tar.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_tar.c @@ -1,6 +1,7 @@ /*- * Copyright (c) 2003-2007 Tim Kientzle * Copyright (c) 2011-2012 Michihiro NAKAJIMA + * Copyright (c) 2016 Martin Matuska * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -203,9 +204,14 @@ static int archive_read_format_tar_read_header(struct archive_read *, struct archive_entry *); static int checksum(struct archive_read *, const void *); static int pax_attribute(struct archive_read *, struct tar *, - struct archive_entry *, const char *key, const char *value); + struct archive_entry *, const char *key, const char *value, + size_t value_length); +static int pax_attribute_acl(struct archive_read *, struct tar *, + struct archive_entry *, const char *, int); +static int pax_attribute_xattr(struct archive_entry *, const char *, + const char *); static int pax_header(struct archive_read *, struct tar *, - struct archive_entry *, char *attr); + struct archive_entry *, struct archive_string *); static void pax_time(const char *, int64_t *sec, long *nanos); static ssize_t readline(struct archive_read *, struct tar *, const char **, ssize_t limit, size_t *); @@ -938,7 +944,7 @@ header_Solaris_ACL(struct archive_read *a, struct tar *tar, { const struct archive_entry_header_ustar *header; size_t size; - int err; + int err, acl_type; int64_t type; char *acl, *p; @@ -983,11 +989,12 @@ header_Solaris_ACL(struct archive_read *a, struct tar *tar, switch ((int)type & ~0777777) { case 01000000: /* POSIX.1e ACL */ + acl_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS; break; case 03000000: - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "Solaris NFSv4 ACLs not supported"); - return (ARCHIVE_WARN); + /* NFSv4 ACL */ + acl_type = ARCHIVE_ENTRY_ACL_TYPE_NFS4; + break; default: archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Malformed Solaris ACL attribute (unsupported type %o)", @@ -1016,8 +1023,8 @@ header_Solaris_ACL(struct archive_read *a, struct tar *tar, return (ARCHIVE_FATAL); } archive_strncpy(&(tar->localname), acl, p - acl); - err = archive_acl_parse_l(archive_entry_acl(entry), - tar->localname.s, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, tar->sconv_acl); + err = archive_acl_from_text_l(archive_entry_acl(entry), + tar->localname.s, acl_type, tar->sconv_acl); if (err != ARCHIVE_OK) { if (errno == ENOMEM) { archive_set_error(&a->archive, ENOMEM, @@ -1478,7 +1485,7 @@ header_pax_extensions(struct archive_read *a, struct tar *tar, * and then skip any fields in the standard header that were * defined in the pax header. */ - err2 = pax_header(a, tar, entry, tar->pax_header.s); + err2 = pax_header(a, tar, entry, &tar->pax_header); err = err_combine(err, err2); tar->entry_padding = 0x1ff & (-tar->entry_bytes_remaining); return (err); @@ -1559,16 +1566,17 @@ header_ustar(struct archive_read *a, struct tar *tar, */ static int pax_header(struct archive_read *a, struct tar *tar, - struct archive_entry *entry, char *attr) + struct archive_entry *entry, struct archive_string *in_as) { - size_t attr_length, l, line_length; + size_t attr_length, l, line_length, value_length; char *p; char *key, *value; struct archive_string *as; struct archive_string_conv *sconv; int err, err2; + char *attr = in_as->s; - attr_length = strlen(attr); + attr_length = in_as->length; tar->pax_hdrcharset_binary = 0; archive_string_empty(&(tar->entry_gname)); archive_string_empty(&(tar->entry_linkpath)); @@ -1633,11 +1641,13 @@ pax_header(struct archive_read *a, struct tar *tar, } *p = '\0'; - /* Identify null-terminated 'value' portion. */ value = p + 1; + /* Some values may be binary data */ + value_length = attr + line_length - 1 - value; + /* Identify this attribute and set it in the entry. */ - err2 = pax_attribute(a, tar, entry, key, value); + err2 = pax_attribute(a, tar, entry, key, value, value_length); if (err2 == ARCHIVE_FATAL) return (err2); err = err_combine(err, err2); @@ -1758,6 +1768,66 @@ pax_attribute_xattr(struct archive_entry *entry, return 0; } +static int +pax_attribute_schily_xattr(struct archive_entry *entry, + const char *name, const char *value, size_t value_length) +{ + if (strlen(name) < 14 || (memcmp(name, "SCHILY.xattr.", 13)) != 0) + return 1; + + name += 13; + + archive_entry_xattr_add_entry(entry, name, value, value_length); + + return 0; +} + +static int +pax_attribute_acl(struct archive_read *a, struct tar *tar, + struct archive_entry *entry, const char *value, int type) +{ + int r; + const char* errstr; + + switch (type) { + case ARCHIVE_ENTRY_ACL_TYPE_ACCESS: + errstr = "SCHILY.acl.access"; + break; + case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT: + errstr = "SCHILY.acl.default"; + break; + case ARCHIVE_ENTRY_ACL_TYPE_NFS4: + errstr = "SCHILY.acl.ace"; + break; + default: + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Unknown ACL type: %d", type); + return(ARCHIVE_FATAL); + } + + if (tar->sconv_acl == NULL) { + tar->sconv_acl = + archive_string_conversion_from_charset( + &(a->archive), "UTF-8", 1); + if (tar->sconv_acl == NULL) + return (ARCHIVE_FATAL); + } + + r = archive_acl_from_text_l(archive_entry_acl(entry), value, type, + tar->sconv_acl); + if (r != ARCHIVE_OK) { + if (r == ARCHIVE_FATAL) { + archive_set_error(&a->archive, ENOMEM, + "%s %s", "Can't allocate memory for ", + errstr); + return (r); + } + archive_set_error(&a->archive, + ARCHIVE_ERRNO_MISC, "%s %s", "Parse error: ", errstr); + } + return (r); +} + /* * Parse a single key=value attribute. key/value pointers are * assumed to point into reasonably long-lived storage. @@ -1773,7 +1843,7 @@ pax_attribute_xattr(struct archive_entry *entry, */ static int pax_attribute(struct archive_read *a, struct tar *tar, - struct archive_entry *entry, const char *key, const char *value) + struct archive_entry *entry, const char *key, const char *value, size_t value_length) { int64_t s; long n; @@ -1876,53 +1946,20 @@ pax_attribute(struct archive_read *a, struct tar *tar, case 'S': /* We support some keys used by the "star" archiver */ if (strcmp(key, "SCHILY.acl.access") == 0) { - if (tar->sconv_acl == NULL) { - tar->sconv_acl = - archive_string_conversion_from_charset( - &(a->archive), "UTF-8", 1); - if (tar->sconv_acl == NULL) - return (ARCHIVE_FATAL); - } - - r = archive_acl_parse_l(archive_entry_acl(entry), - value, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - tar->sconv_acl); - if (r != ARCHIVE_OK) { - err = r; - if (err == ARCHIVE_FATAL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate memory for " - "SCHILY.acl.access"); - return (err); - } - archive_set_error(&a->archive, - ARCHIVE_ERRNO_MISC, - "Parse error: SCHILY.acl.access"); - } + r = pax_attribute_acl(a, tar, entry, value, + ARCHIVE_ENTRY_ACL_TYPE_ACCESS); + if (r == ARCHIVE_FATAL) + return (r); } else if (strcmp(key, "SCHILY.acl.default") == 0) { - if (tar->sconv_acl == NULL) { - tar->sconv_acl = - archive_string_conversion_from_charset( - &(a->archive), "UTF-8", 1); - if (tar->sconv_acl == NULL) - return (ARCHIVE_FATAL); - } - - r = archive_acl_parse_l(archive_entry_acl(entry), - value, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, - tar->sconv_acl); - if (r != ARCHIVE_OK) { - err = r; - if (err == ARCHIVE_FATAL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate memory for " - "SCHILY.acl.default"); - return (err); - } - archive_set_error(&a->archive, - ARCHIVE_ERRNO_MISC, - "Parse error: SCHILY.acl.default"); - } + r = pax_attribute_acl(a, tar, entry, value, + ARCHIVE_ENTRY_ACL_TYPE_DEFAULT); + if (r == ARCHIVE_FATAL) + return (r); + } else if (strcmp(key, "SCHILY.acl.ace") == 0) { + r = pax_attribute_acl(a, tar, entry, value, + ARCHIVE_ENTRY_ACL_TYPE_NFS4); + if (r == ARCHIVE_FATAL) + return (r); } else if (strcmp(key, "SCHILY.devmajor") == 0) { archive_entry_set_rdevmajor(entry, (dev_t)tar_atol10(value, strlen(value))); @@ -1943,6 +1980,9 @@ pax_attribute(struct archive_read *a, struct tar *tar, } else if (strcmp(key, "SCHILY.realsize") == 0) { tar->realsize = tar_atol10(value, strlen(value)); archive_entry_set_size(entry, tar->realsize); + } else if (strncmp(key, "SCHILY.xattr.", 13) == 0) { + pax_attribute_schily_xattr(entry, key, value, + value_length); } else if (strcmp(key, "SUN.holesdata") == 0) { /* A Solaris extension for sparse. */ r = solaris_sparse_parse(a, tar, entry, value); diff --git a/contrib/libarchive/libarchive/archive_read_support_format_warc.c b/contrib/libarchive/libarchive/archive_read_support_format_warc.c index a287fc2..30cdaf9 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_warc.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_warc.c @@ -88,7 +88,7 @@ typedef enum { WT_RVIS, /* conversion, unsupported */ WT_CONV, - /* continutation, unsupported at the moment */ + /* continuation, unsupported at the moment */ WT_CONT, /* invalid type */ LAST_WT @@ -534,7 +534,7 @@ xstrpisotime(const char *s, char **endptr) /* as a courtesy to our callers, and since this is a non-standard * routine, we skip leading whitespace */ - while (isspace((unsigned char)*s)) + while (isblank((unsigned char)*s)) ++s; /* read year */ @@ -562,7 +562,7 @@ xstrpisotime(const char *s, char **endptr) goto out; } - /* massage TM to fulfill some of POSIX' contraints */ + /* massage TM to fulfill some of POSIX' constraints */ tm.tm_year -= 1900; tm.tm_mon--; diff --git a/contrib/libarchive/libarchive/archive_read_support_format_xar.c b/contrib/libarchive/libarchive/archive_read_support_format_xar.c index 47ed064..d3002af 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_xar.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_xar.c @@ -933,6 +933,7 @@ xar_cleanup(struct archive_read *a) } for (i = 0; i < xar->file_queue.used; i++) file_free(xar->file_queue.files[i]); + free(xar->file_queue.files); while (xar->unknowntags != NULL) { struct unknown_tag *tag; @@ -3047,7 +3048,7 @@ xml2_read_cb(void *context, char *buffer, int len) struct xar *xar; const void *d; size_t outbytes; - size_t used; + size_t used = 0; int r; a = (struct archive_read *)context; @@ -3171,6 +3172,9 @@ expat_xmlattr_setup(struct archive_read *a, value = strdup(atts[1]); if (attr == NULL || name == NULL || value == NULL) { archive_set_error(&a->archive, ENOMEM, "Out of memory"); + free(attr); + free(name); + free(value); return (ARCHIVE_FATAL); } attr->name = name; diff --git a/contrib/libarchive/libarchive/archive_read_support_format_zip.c b/contrib/libarchive/libarchive/archive_read_support_format_zip.c index 1aa7445..53373ff 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_zip.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_zip.c @@ -199,7 +199,7 @@ struct zip { struct trad_enc_ctx tctx; char tctx_valid; - /* WinZip AES decyption. */ + /* WinZip AES decryption. */ /* Contexts used for AES decryption. */ archive_crypto_ctx cctx; char cctx_valid; @@ -242,7 +242,7 @@ trad_enc_update_keys(struct trad_enc_ctx *ctx, uint8_t c) } static uint8_t -trad_enc_decypt_byte(struct trad_enc_ctx *ctx) +trad_enc_decrypt_byte(struct trad_enc_ctx *ctx) { unsigned temp = ctx->keys[2] | 2; return (uint8_t)((temp * (temp ^ 1)) >> 8) & 0xff; @@ -257,7 +257,7 @@ trad_enc_decrypt_update(struct trad_enc_ctx *ctx, const uint8_t *in, max = (unsigned)((in_len < out_len)? in_len: out_len); for (i = 0; i < max; i++) { - uint8_t t = in[i] ^ trad_enc_decypt_byte(ctx); + uint8_t t = in[i] ^ trad_enc_decrypt_byte(ctx); out[i] = t; trad_enc_update_keys(ctx, t); } @@ -710,7 +710,7 @@ process_extra(struct archive_read *a, const char *p, size_t extra_length, struct break; } case 0x9901: - /* WinZIp AES extra data field. */ + /* WinZip AES extra data field. */ if (p[offset + 2] == 'A' && p[offset + 3] == 'E') { /* Vendor version. */ zip_entry->aes_extra.vendor = @@ -905,6 +905,7 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry, archive_wstrcat(&s, wp); archive_wstrappend_wchar(&s, L'/'); archive_entry_copy_pathname_w(entry, s.s); + archive_wstring_free(&s); } } else { cp = archive_entry_pathname(entry); @@ -915,6 +916,7 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry, archive_strcat(&s, cp); archive_strappend_char(&s, '/'); archive_entry_set_pathname(entry, s.s); + archive_string_free(&s); } } } @@ -1518,7 +1520,7 @@ read_decryption_header(struct archive_read *a) case 0x6720:/* Blowfish */ case 0x6721:/* Twofish */ case 0x6801:/* RC4 */ - /* Suuported encryption algorithm. */ + /* Supported encryption algorithm. */ break; default: archive_set_error(&a->archive, @@ -1627,7 +1629,7 @@ read_decryption_header(struct archive_read *a) __archive_read_consume(a, 4); /*return (ARCHIVE_OK); - * This is not fully implemnted yet.*/ + * This is not fully implemented yet.*/ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Encrypted file is unsupported"); return (ARCHIVE_FAILED); @@ -1709,7 +1711,7 @@ init_traditional_PKWARE_decryption(struct archive_read *a) } /* - * Initialize ctx for Traditional PKWARE Decyption. + * Initialize ctx for Traditional PKWARE Decryption. */ r = trad_enc_init(&zip->tctx, passphrase, strlen(passphrase), p, ENC_HEADER_SIZE, &crcchk); diff --git a/contrib/libarchive/libarchive/archive_string.c b/contrib/libarchive/libarchive/archive_string.c index cf10f09..f738c54 100644 --- a/contrib/libarchive/libarchive/archive_string.c +++ b/contrib/libarchive/libarchive/archive_string.c @@ -219,6 +219,12 @@ archive_wstring_append(struct archive_wstring *as, const wchar_t *p, size_t s) return (as); } +struct archive_string * +archive_array_append(struct archive_string *as, const char *p, size_t s) +{ + return archive_string_append(as, p, s); +} + void archive_string_concat(struct archive_string *dest, struct archive_string *src) { @@ -597,7 +603,7 @@ archive_wstring_append_from_mbs(struct archive_wstring *dest, wcs = dest->s + dest->length; /* * We cannot use mbsrtowcs/mbstowcs here because those may convert - * extra MBS when strlen(p) > len and one wide character consis of + * extra MBS when strlen(p) > len and one wide character consists of * multi bytes. */ while (*mbs && mbs_length > 0) { @@ -1248,7 +1254,7 @@ create_sconv_object(const char *fc, const char *tc, sc->cd = iconv_open(tc, fc); if (sc->cd == (iconv_t)-1 && (sc->flag & SCONV_BEST_EFFORT)) { /* - * Unfortunaly, all of iconv implements do support + * Unfortunately, all of iconv implements do support * "CP932" character-set, so we should use "SJIS" * instead if iconv_open failed. */ @@ -1261,7 +1267,7 @@ create_sconv_object(const char *fc, const char *tc, /* * archive_mstring on Windows directly convert multi-bytes * into archive_wstring in order not to depend on locale - * so that you can do a I18N programing. This will be + * so that you can do a I18N programming. This will be * used only in archive_mstring_copy_mbs_len_l so far. */ if (flag & SCONV_FROM_CHARSET) { @@ -1726,7 +1732,7 @@ archive_string_conversion_from_charset(struct archive *a, const char *charset, * in tar or zip files. But mbstowcs/wcstombs(CRT) usually use CP_ACP * unless you use setlocale(LC_ALL, ".OCP")(specify CP_OEMCP). * So we should make a string conversion between CP_ACP and CP_OEMCP - * for compatibillty. + * for compatibility. */ #if defined(_WIN32) && !defined(__CYGWIN__) struct archive_string_conv * @@ -2220,7 +2226,7 @@ best_effort_strncat_in_locale(struct archive_string *as, const void *_p, /* * If a character is ASCII, this just copies it. If not, this - * assigns '?' charater instead but in UTF-8 locale this assigns + * assigns '?' character instead but in UTF-8 locale this assigns * byte sequence 0xEF 0xBD 0xBD, which are code point U+FFFD, * a Replacement Character in Unicode. */ @@ -2554,7 +2560,7 @@ utf16_to_unicode(uint32_t *pwc, const char *s, size_t n, int be) /* * Surrogate pair values(0xd800 through 0xdfff) are only - * used by UTF-16, so, after above culculation, the code + * used by UTF-16, so, after above calculation, the code * must not be surrogate values, and Unicode has no codes * larger than 0x10ffff. Thus, those are not legal Unicode * values. @@ -2903,7 +2909,7 @@ get_nfc(uint32_t uc, uint32_t uc2) /* * Normalize UTF-8/UTF-16BE characters to Form C and copy the result. * - * TODO: Convert composition exclusions,which are never converted + * TODO: Convert composition exclusions, which are never converted * from NFC,NFD,NFKC and NFKD, to Form C. */ static int @@ -3437,7 +3443,7 @@ strncat_from_utf8_libarchive2(struct archive_string *as, } /* - * As libarchie 2.x, translates the UTF-8 characters into + * As libarchive 2.x, translates the UTF-8 characters into * wide-characters in the assumption that WCS is Unicode. */ if (n < 0) { @@ -3947,7 +3953,7 @@ archive_mstring_get_mbs_l(struct archive_mstring *aes, #if defined(_WIN32) && !defined(__CYGWIN__) /* - * Internationalization programing on Windows must use Wide + * Internationalization programming on Windows must use Wide * characters because Windows platform cannot make locale UTF-8. */ if (sc != NULL && (aes->aes_set & AES_SET_WCS) != 0) { @@ -4079,7 +4085,7 @@ archive_mstring_copy_mbs_len_l(struct archive_mstring *aes, archive_string_empty(&(aes->aes_utf8)); #if defined(_WIN32) && !defined(__CYGWIN__) /* - * Internationalization programing on Windows must use Wide + * Internationalization programming on Windows must use Wide * characters because Windows platform cannot make locale UTF-8. */ if (sc == NULL) { diff --git a/contrib/libarchive/libarchive/archive_string.h b/contrib/libarchive/libarchive/archive_string.h index 60ebf0e..f5953d0 100644 --- a/contrib/libarchive/libarchive/archive_string.h +++ b/contrib/libarchive/libarchive/archive_string.h @@ -81,6 +81,10 @@ archive_strappend_char(struct archive_string *, char); struct archive_wstring * archive_wstrappend_wchar(struct archive_wstring *, wchar_t); +/* Append a raw array to an archive_string, resizing as necessary */ +struct archive_string * +archive_array_append(struct archive_string *, const char *, size_t); + /* Convert a Unicode string to current locale and append the result. */ /* Returns -1 if conversion fails. */ int diff --git a/contrib/libarchive/libarchive/archive_string_composition.h b/contrib/libarchive/libarchive/archive_string_composition.h index be41e33..8902ac1 100644 --- a/contrib/libarchive/libarchive/archive_string_composition.h +++ b/contrib/libarchive/libarchive/archive_string_composition.h @@ -1009,7 +1009,7 @@ static const char u_decomposable_blocks[0x1D2+1] = { (((uc) > 0x1D244)?0:\ ccc_val[ccc_val_index[ccc_index[(uc)>>8]][((uc)>>4)&0x0F]][(uc)&0x0F]) -/* The table of the value of Canonical Cimbining Class */ +/* The table of the value of Canonical Combining Class */ static const unsigned char ccc_val[][16] = { /* idx=0: XXXX0 - XXXXF */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, diff --git a/contrib/libarchive/libarchive/archive_write.c b/contrib/libarchive/libarchive/archive_write.c index f5a9f61..e441dbe 100644 --- a/contrib/libarchive/libarchive/archive_write.c +++ b/contrib/libarchive/libarchive/archive_write.c @@ -231,7 +231,7 @@ __archive_write_filter(struct archive_write_filter *f, if (length == 0) return(ARCHIVE_OK); if (f->write == NULL) - /* If unset, a fatal error has already ocuured, so this filter + /* If unset, a fatal error has already occurred, so this filter * didn't open. We cannot write anything. */ return(ARCHIVE_FATAL); r = (f->write)(f, buff, length); diff --git a/contrib/libarchive/libarchive/archive_write_add_filter_program.c b/contrib/libarchive/libarchive/archive_write_add_filter_program.c index 31a1b6f..55b5e8e 100644 --- a/contrib/libarchive/libarchive/archive_write_add_filter_program.c +++ b/contrib/libarchive/libarchive/archive_write_add_filter_program.c @@ -200,6 +200,7 @@ __archive_write_program_free(struct archive_write_program_data *data) if (data->child) CloseHandle(data->child); #endif + free(data->program_name); free(data->child_buf); free(data); } diff --git a/contrib/libarchive/libarchive/archive_write_add_filter_xz.c b/contrib/libarchive/libarchive/archive_write_add_filter_xz.c index 46a6c38..b0f25a6 100644 --- a/contrib/libarchive/libarchive/archive_write_add_filter_xz.c +++ b/contrib/libarchive/libarchive/archive_write_add_filter_xz.c @@ -233,7 +233,7 @@ archive_compressor_xz_init_stream(struct archive_write_filter *f, if (f->code == ARCHIVE_FILTER_XZ) { #ifdef HAVE_LZMA_STREAM_ENCODER_MT if (data->threads != 1) { - bzero(&mt_options, sizeof(mt_options)); + memset(&mt_options, 0, sizeof(mt_options)); mt_options.threads = data->threads; mt_options.timeout = 300; mt_options.filters = data->lzmafilters; diff --git a/contrib/libarchive/libarchive/archive_write_disk_acl.c b/contrib/libarchive/libarchive/archive_write_disk_acl.c index e47384a..311aebf 100644 --- a/contrib/libarchive/libarchive/archive_write_disk_acl.c +++ b/contrib/libarchive/libarchive/archive_write_disk_acl.c @@ -34,6 +34,9 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_disk.c 201159 2009-12-29 0 #define _ACL_PRIVATE /* For debugging */ #include #endif +#if HAVE_DARWIN_ACL +#include +#endif #ifdef HAVE_ERRNO_H #include #endif @@ -43,7 +46,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_disk.c 201159 2009-12-29 0 #include "archive_acl_private.h" #include "archive_write_disk_private.h" -#ifndef HAVE_POSIX_ACL +#if !HAVE_POSIX_ACL && !HAVE_NFS4_ACL /* Default empty function body to satisfy mainline code. */ int archive_write_disk_set_acls(struct archive *a, int fd, const char *name, @@ -56,47 +59,111 @@ archive_write_disk_set_acls(struct archive *a, int fd, const char *name, return (ARCHIVE_OK); } -#else +#else /* HAVE_POSIX_ACL || HAVE_NFS4_ACL */ + +#if HAVE_SUN_ACL +#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACE_T +#elif HAVE_DARWIN_ACL +#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACL_TYPE_EXTENDED +#elif HAVE_ACL_TYPE_NFS4 +#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACL_TYPE_NFS4 +#endif static int set_acl(struct archive *, int fd, const char *, struct archive_acl *, acl_type_t, int archive_entry_acl_type, const char *tn); -/* - * XXX TODO: What about ACL types other than ACCESS and DEFAULT? - */ int archive_write_disk_set_acls(struct archive *a, int fd, const char *name, struct archive_acl *abstract_acl) { - int ret; + int ret = ARCHIVE_OK; - if (archive_acl_count(abstract_acl, ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) > 0) { - ret = set_acl(a, fd, name, abstract_acl, ACL_TYPE_ACCESS, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, "access"); - if (ret != ARCHIVE_OK) - return (ret); - ret = set_acl(a, fd, name, abstract_acl, ACL_TYPE_DEFAULT, - ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, "default"); +#if !HAVE_DARWIN_ACL + if ((archive_acl_types(abstract_acl) + & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) { +#if HAVE_SUN_ACL + /* Solaris writes POSIX.1e access and default ACLs together */ + ret = set_acl(a, fd, name, abstract_acl, ACLENT_T, + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, "posix1e"); +#else /* HAVE_POSIX_ACL */ + if ((archive_acl_types(abstract_acl) + & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) { + ret = set_acl(a, fd, name, abstract_acl, + ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, + "access"); + if (ret != ARCHIVE_OK) + return (ret); + } + if ((archive_acl_types(abstract_acl) + & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) + ret = set_acl(a, fd, name, abstract_acl, + ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, + "default"); +#endif /* !HAVE_SUN_ACL */ + /* Simultaeous POSIX.1e and NFSv4 is not supported */ return (ret); -#ifdef ACL_TYPE_NFS4 - } else if (archive_acl_count(abstract_acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4) > 0) { - ret = set_acl(a, fd, name, abstract_acl, ACL_TYPE_NFS4, + } +#endif /* !HAVE_DARWIN_ACL */ +#if HAVE_NFS4_ACL + if ((archive_acl_types(abstract_acl) & + ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) { + ret = set_acl(a, fd, name, abstract_acl, + ARCHIVE_PLATFORM_ACL_TYPE_NFS4, ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4"); - return (ret); -#endif - } else - return ARCHIVE_OK; + } +#endif /* HAVE_NFS4_ACL */ + return (ret); } +/* + * Translate system ACL permissions into libarchive internal structure + */ static struct { int archive_perm; int platform_perm; } acl_perm_map[] = { +#if HAVE_SUN_ACL /* Solaris NFSv4 ACL permissions */ + {ARCHIVE_ENTRY_ACL_EXECUTE, ACE_EXECUTE}, + {ARCHIVE_ENTRY_ACL_READ_DATA, ACE_READ_DATA}, + {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACE_LIST_DIRECTORY}, + {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACE_WRITE_DATA}, + {ARCHIVE_ENTRY_ACL_ADD_FILE, ACE_ADD_FILE}, + {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACE_APPEND_DATA}, + {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACE_ADD_SUBDIRECTORY}, + {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACE_READ_NAMED_ATTRS}, + {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACE_WRITE_NAMED_ATTRS}, + {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACE_DELETE_CHILD}, + {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACE_READ_ATTRIBUTES}, + {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACE_WRITE_ATTRIBUTES}, + {ARCHIVE_ENTRY_ACL_DELETE, ACE_DELETE}, + {ARCHIVE_ENTRY_ACL_READ_ACL, ACE_READ_ACL}, + {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACE_WRITE_ACL}, + {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACE_WRITE_OWNER}, + {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACE_SYNCHRONIZE} +#elif HAVE_DARWIN_ACL /* MacOS ACL permissions */ + {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA}, + {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY}, + {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA}, + {ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE}, + {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE}, + {ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE}, + {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA}, + {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY}, + {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD}, + {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES}, + {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES}, + {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_EXTATTRIBUTES}, + {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_EXTATTRIBUTES}, + {ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_SECURITY}, + {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_SECURITY}, + {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_CHANGE_OWNER}, + {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE} +#else /* POSIX.1e ACL permissions */ {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE}, {ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE}, {ARCHIVE_ENTRY_ACL_READ, ACL_READ}, -#ifdef ACL_TYPE_NFS4 +#if HAVE_ACL_TYPE_NFS4 /* FreeBSD NFSv4 ACL permissions */ {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA}, {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY}, {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA}, @@ -114,34 +181,69 @@ static struct { {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER}, {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE} #endif +#endif /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */ }; -#ifdef ACL_TYPE_NFS4 +#if HAVE_NFS4_ACL +/* + * Translate system NFSv4 inheritance flags into libarchive internal structure + */ static struct { int archive_inherit; int platform_inherit; } acl_inherit_map[] = { +#if HAVE_SUN_ACL /* Solaris NFSv4 inheritance flags */ + {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACE_FILE_INHERIT_ACE}, + {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACE_DIRECTORY_INHERIT_ACE}, + {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACE_NO_PROPAGATE_INHERIT_ACE}, + {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACE_INHERIT_ONLY_ACE}, + {ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACE_SUCCESSFUL_ACCESS_ACE_FLAG}, + {ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACE_FAILED_ACCESS_ACE_FLAG}, + {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACE_INHERITED_ACE} +#elif HAVE_DARWIN_ACL /* MacOS NFSv4 inheritance flags */ + {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED}, + {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT}, + {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT}, + {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_LIMIT_INHERIT}, + {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_ONLY_INHERIT} +#else /* FreeBSD NFSv4 ACL inheritance flags */ {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT}, {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT}, {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_NO_PROPAGATE_INHERIT}, - {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY} + {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY}, + {ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACL_ENTRY_SUCCESSFUL_ACCESS}, + {ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACL_ENTRY_FAILED_ACCESS}, + {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED} +#endif /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */ }; -#endif +#endif /* HAVE_NFS4_ACL */ static int set_acl(struct archive *a, int fd, const char *name, struct archive_acl *abstract_acl, acl_type_t acl_type, int ae_requested_type, const char *tname) { +#if HAVE_SUN_ACL + aclent_t *aclent; + ace_t *ace; + int e, r; + acl_t *acl; +#else acl_t acl; acl_entry_t acl_entry; acl_permset_t acl_permset; -#ifdef ACL_TYPE_NFS4 +#if HAVE_ACL_TYPE_NFS4 || HAVE_DARWIN_ACL acl_flagset_t acl_flagset; - int r; +#endif +#endif /* HAVE_SUN_ACL */ +#if HAVE_ACL_TYPE_NFS4 + int r; #endif int ret; int ae_type, ae_permset, ae_tag, ae_id; +#if HAVE_DARWIN_ACL + uuid_t ae_uuid; +#endif uid_t ae_uid; gid_t ae_gid; const char *ae_name; @@ -152,32 +254,165 @@ set_acl(struct archive *a, int fd, const char *name, entries = archive_acl_reset(abstract_acl, ae_requested_type); if (entries == 0) return (ARCHIVE_OK); + +#if HAVE_SUN_ACL + acl = NULL; + acl = malloc(sizeof(acl_t)); + if (acl == NULL) { + archive_set_error(a, ARCHIVE_ERRNO_MISC, + "Invalid ACL type"); + return (ARCHIVE_FAILED); + } + if (acl_type == ACE_T) + acl->acl_entry_size = sizeof(ace_t); + else if (acl_type == ACLENT_T) + acl->acl_entry_size = sizeof(aclent_t); + else { + archive_set_error(a, ARCHIVE_ERRNO_MISC, + "Invalid ACL type"); + acl_free(acl); + return (ARCHIVE_FAILED); + } + acl->acl_type = acl_type; + acl->acl_cnt = entries; + + acl->acl_aclp = malloc(entries * acl->acl_entry_size); + if (acl->acl_aclp == NULL) { + archive_set_error(a, errno, + "Can't allocate memory for acl buffer"); + acl_free(acl); + return (ARCHIVE_FAILED); + } +#else /* !HAVE_SUN_ACL */ acl = acl_init(entries); if (acl == (acl_t)NULL) { archive_set_error(a, errno, "Failed to initialize ACL working storage"); return (ARCHIVE_FAILED); } +#endif /* !HAVE_SUN_ACL */ +#if HAVE_SUN_ACL + e = 0; +#endif while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type, &ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) { +#if HAVE_SUN_ACL + ace = NULL; + aclent = NULL; + if (acl->acl_type == ACE_T) { + ace = &((ace_t *)acl->acl_aclp)[e]; + ace->a_who = -1; + ace->a_access_mask = 0; + ace->a_flags = 0; + } else { + aclent = &((aclent_t *)acl->acl_aclp)[e]; + aclent->a_id = -1; + aclent->a_type = 0; + aclent->a_perm = 0; + } +#else /* !HAVE_SUN_ACL */ +#if HAVE_DARWIN_ACL + /* + * Mac OS doesn't support NFSv4 ACLs for + * owner@, group@ and everyone@. + * We skip any of these ACLs found. + */ + if (ae_tag == ARCHIVE_ENTRY_ACL_USER_OBJ || + ae_tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ || + ae_tag == ARCHIVE_ENTRY_ACL_EVERYONE) + continue; +#endif if (acl_create_entry(&acl, &acl_entry) != 0) { archive_set_error(a, errno, "Failed to create a new ACL entry"); ret = ARCHIVE_FAILED; goto exit_free; } - +#endif /* !HAVE_SUN_ACL */ +#if HAVE_DARWIN_ACL + switch (ae_type) { + case ARCHIVE_ENTRY_ACL_TYPE_ALLOW: + acl_set_tag_type(acl_entry, ACL_EXTENDED_ALLOW); + break; + case ARCHIVE_ENTRY_ACL_TYPE_DENY: + acl_set_tag_type(acl_entry, ACL_EXTENDED_DENY); + break; + default: + /* We don't support any other types on MacOS */ + continue; + } +#endif switch (ae_tag) { +#if HAVE_SUN_ACL case ARCHIVE_ENTRY_ACL_USER: - acl_set_tag_type(acl_entry, ACL_USER); ae_uid = archive_write_disk_uid(a, ae_name, ae_id); + if (acl->acl_type == ACE_T) + ace->a_who = ae_uid; + else { + aclent->a_id = ae_uid; + aclent->a_type |= USER; + } + break; + case ARCHIVE_ENTRY_ACL_GROUP: + ae_gid = archive_write_disk_gid(a, ae_name, ae_id); + if (acl->acl_type == ACE_T) { + ace->a_who = ae_gid; + ace->a_flags |= ACE_IDENTIFIER_GROUP; + } else { + aclent->a_id = ae_gid; + aclent->a_type |= GROUP; + } + break; + case ARCHIVE_ENTRY_ACL_USER_OBJ: + if (acl->acl_type == ACE_T) + ace->a_flags |= ACE_OWNER; + else + aclent->a_type |= USER_OBJ; + break; + case ARCHIVE_ENTRY_ACL_GROUP_OBJ: + if (acl->acl_type == ACE_T) { + ace->a_flags |= ACE_GROUP; + ace->a_flags |= ACE_IDENTIFIER_GROUP; + } else + aclent->a_type |= GROUP_OBJ; + break; + case ARCHIVE_ENTRY_ACL_MASK: + aclent->a_type |= CLASS_OBJ; + break; + case ARCHIVE_ENTRY_ACL_OTHER: + aclent->a_type |= OTHER_OBJ; + break; + case ARCHIVE_ENTRY_ACL_EVERYONE: + ace->a_flags |= ACE_EVERYONE; + break; +#else /* !HAVE_SUN_ACL */ + case ARCHIVE_ENTRY_ACL_USER: + ae_uid = archive_write_disk_uid(a, ae_name, ae_id); +#if !HAVE_DARWIN_ACL /* FreeBSD, Linux */ + acl_set_tag_type(acl_entry, ACL_USER); acl_set_qualifier(acl_entry, &ae_uid); +#else /* MacOS */ + if (mbr_identifier_to_uuid(ID_TYPE_UID, &ae_uid, + sizeof(uid_t), ae_uuid) != 0) + continue; + if (acl_set_qualifier(acl_entry, &ae_uuid) != 0) + continue; +#endif /* HAVE_DARWIN_ACL */ break; case ARCHIVE_ENTRY_ACL_GROUP: - acl_set_tag_type(acl_entry, ACL_GROUP); ae_gid = archive_write_disk_gid(a, ae_name, ae_id); +#if !HAVE_DARWIN_ACL /* FreeBSD, Linux */ + acl_set_tag_type(acl_entry, ACL_GROUP); acl_set_qualifier(acl_entry, &ae_gid); +#else /* MacOS */ + if (mbr_identifier_to_uuid(ID_TYPE_GID, &ae_gid, + sizeof(gid_t), ae_uuid) != 0) + continue; + if (acl_set_qualifier(acl_entry, &ae_uuid) != 0) + continue; +#endif /* HAVE_DARWIN_ACL */ break; +#if !HAVE_DARWIN_ACL /* FreeBSD, Linux */ case ARCHIVE_ENTRY_ACL_USER_OBJ: acl_set_tag_type(acl_entry, ACL_USER_OBJ); break; @@ -190,11 +425,13 @@ set_acl(struct archive *a, int fd, const char *name, case ARCHIVE_ENTRY_ACL_OTHER: acl_set_tag_type(acl_entry, ACL_OTHER); break; -#ifdef ACL_TYPE_NFS4 +#if HAVE_ACL_TYPE_NFS4 /* FreeBSD only */ case ARCHIVE_ENTRY_ACL_EVERYONE: acl_set_tag_type(acl_entry, ACL_EVERYONE); break; #endif +#endif /* !HAVE_DARWIN_ACL */ +#endif /* !HAVE_SUN_ACL */ default: archive_set_error(a, ARCHIVE_ERRNO_MISC, "Unknown ACL tag"); @@ -202,9 +439,45 @@ set_acl(struct archive *a, int fd, const char *name, goto exit_free; } -#ifdef ACL_TYPE_NFS4 +#if HAVE_ACL_TYPE_NFS4 || HAVE_SUN_ACL r = 0; switch (ae_type) { +#if HAVE_SUN_ACL + case ARCHIVE_ENTRY_ACL_TYPE_ALLOW: + if (ace != NULL) + ace->a_type = ACE_ACCESS_ALLOWED_ACE_TYPE; + else + r = -1; + break; + case ARCHIVE_ENTRY_ACL_TYPE_DENY: + if (ace != NULL) + ace->a_type = ACE_ACCESS_DENIED_ACE_TYPE; + else + r = -1; + break; + case ARCHIVE_ENTRY_ACL_TYPE_AUDIT: + if (ace != NULL) + ace->a_type = ACE_SYSTEM_AUDIT_ACE_TYPE; + else + r = -1; + break; + case ARCHIVE_ENTRY_ACL_TYPE_ALARM: + if (ace != NULL) + ace->a_type = ACE_SYSTEM_ALARM_ACE_TYPE; + else + r = -1; + break; + case ARCHIVE_ENTRY_ACL_TYPE_ACCESS: + if (aclent == NULL) + r = -1; + break; + case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT: + if (aclent != NULL) + aclent->a_type |= ACL_DEFAULT; + else + r = -1; + break; +#else /* !HAVE_SUN_ACL */ case ARCHIVE_ENTRY_ACL_TYPE_ALLOW: r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALLOW); break; @@ -221,20 +494,35 @@ set_acl(struct archive *a, int fd, const char *name, case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT: // These don't translate directly into the system ACL. break; +#endif /* !HAVE_SUN_ACL */ default: archive_set_error(a, ARCHIVE_ERRNO_MISC, "Unknown ACL entry type"); ret = ARCHIVE_FAILED; goto exit_free; } + if (r != 0) { +#if HAVE_SUN_ACL + errno = EINVAL; +#endif archive_set_error(a, errno, "Failed to set ACL entry type"); ret = ARCHIVE_FAILED; goto exit_free; } -#endif +#endif /* HAVE_ACL_TYPE_NFS4 || HAVE_SUN_ACL */ +#if HAVE_SUN_ACL + if (acl->acl_type == ACLENT_T) { + if (ae_permset & ARCHIVE_ENTRY_ACL_EXECUTE) + aclent->a_perm |= 1; + if (ae_permset & ARCHIVE_ENTRY_ACL_WRITE) + aclent->a_perm |= 2; + if (ae_permset & ARCHIVE_ENTRY_ACL_READ) + aclent->a_perm |= 4; + } else +#else if (acl_get_permset(acl_entry, &acl_permset) != 0) { archive_set_error(a, errno, "Failed to get ACL permission set"); @@ -247,9 +535,13 @@ set_acl(struct archive *a, int fd, const char *name, ret = ARCHIVE_FAILED; goto exit_free; } - +#endif /* !HAVE_SUN_ACL */ for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) { - if (ae_permset & acl_perm_map[i].archive_perm) + if (ae_permset & acl_perm_map[i].archive_perm) { +#if HAVE_SUN_ACL + ace->a_access_mask |= + acl_perm_map[i].platform_perm; +#else if (acl_add_perm(acl_permset, acl_perm_map[i].platform_perm) != 0) { archive_set_error(a, errno, @@ -257,10 +549,20 @@ set_acl(struct archive *a, int fd, const char *name, ret = ARCHIVE_FAILED; goto exit_free; } +#endif + } } -#ifdef ACL_TYPE_NFS4 - if (acl_type == ACL_TYPE_NFS4) { +#if HAVE_NFS4_ACL +#if HAVE_SUN_ACL + if (acl_type == ACE_T) +#elif HAVE_DARWIN_ACL + if (acl_type == ACL_TYPE_EXTENDED) +#else /* FreeBSD */ + if (acl_type == ACL_TYPE_NFS4) +#endif + { +#if HAVE_POSIX_ACL || HAVE_DARWIN_ACL /* * acl_get_flagset_np() fails with non-NFSv4 ACLs */ @@ -276,8 +578,13 @@ set_acl(struct archive *a, int fd, const char *name, ret = ARCHIVE_FAILED; goto exit_free; } - for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) { +#endif /* HAVE_POSIX_ACL || HAVE_DARWIN_ACL */ + for (i = 0; i < (int)(sizeof(acl_inherit_map) /sizeof(acl_inherit_map[0])); ++i) { if (ae_permset & acl_inherit_map[i].archive_inherit) { +#if HAVE_SUN_ACL + ace->a_flags |= + acl_inherit_map[i].platform_inherit; +#else /* !HAVE_SUN_ACL */ if (acl_add_flag_np(acl_flagset, acl_inherit_map[i].platform_inherit) != 0) { archive_set_error(a, errno, @@ -285,38 +592,63 @@ set_acl(struct archive *a, int fd, const char *name, ret = ARCHIVE_FAILED; goto exit_free; } +#endif /* HAVE_SUN_ACL */ } } } +#endif /* HAVE_NFS4_ACL */ +#if HAVE_SUN_ACL + e++; #endif } +#if HAVE_ACL_SET_FD_NP || HAVE_ACL_SET_FD || HAVE_SUN_ACL /* Try restoring the ACL through 'fd' if we can. */ -#if HAVE_ACL_SET_FD - if (fd >= 0 && acl_type == ACL_TYPE_ACCESS && acl_set_fd(fd, acl) == 0) - ret = ARCHIVE_OK; - else -#else -#if HAVE_ACL_SET_FD_NP - if (fd >= 0 && acl_set_fd_np(fd, acl, acl_type) == 0) - ret = ARCHIVE_OK; - else +#if HAVE_SUN_ACL || HAVE_ACL_SET_FD_NP + if (fd >= 0) +#else /* !HAVE_SUN_ACL && !HAVE_ACL_SET_FD_NP */ + if (fd >= 0 && acl_type == ACL_TYPE_ACCESS) #endif + { +#if HAVE_SUN_ACL + if (facl_set(fd, acl) == 0) +#elif HAVE_ACL_SET_FD_NP + if (acl_set_fd_np(fd, acl, acl_type) == 0) +#else /* !HAVE_SUN_ACL && !HAVE_ACL_SET_FD_NP */ + if (acl_set_fd(fd, acl) == 0) #endif -#if HAVE_ACL_SET_LINK_NP - if (acl_set_link_np(name, acl_type, acl) != 0) { - archive_set_error(a, errno, "Failed to set %s acl", tname); - ret = ARCHIVE_WARN; - } + ret = ARCHIVE_OK; + else { + if (errno == EOPNOTSUPP) { + /* Filesystem doesn't support ACLs */ + ret = ARCHIVE_OK; + } else { + archive_set_error(a, errno, + "Failed to set %s acl on fd", tname); + } + } + } else +#endif /* HAVE_ACL_SET_FD_NP || HAVE_ACL_SET_FD || HAVE_SUN_ACL */ +#if HAVE_SUN_ACL + if (acl_set(name, acl) != 0) +#elif HAVE_ACL_SET_LINK_NP + if (acl_set_link_np(name, acl_type, acl) != 0) #else /* TODO: Skip this if 'name' is a symlink. */ - if (acl_set_file(name, acl_type, acl) != 0) { - archive_set_error(a, errno, "Failed to set %s acl", tname); - ret = ARCHIVE_WARN; - } + if (acl_set_file(name, acl_type, acl) != 0) #endif + { + if (errno == EOPNOTSUPP) { + /* Filesystem doesn't support ACLs */ + ret = ARCHIVE_OK; + } else { + archive_set_error(a, errno, "Failed to set %s acl", + tname); + ret = ARCHIVE_WARN; + } + } exit_free: acl_free(acl); return (ret); } -#endif +#endif /* HAVE_POSIX_ACL || HAVE_NFS4_ACL */ diff --git a/contrib/libarchive/libarchive/archive_write_disk_posix.c b/contrib/libarchive/libarchive/archive_write_disk_posix.c index c05059a..a799524 100644 --- a/contrib/libarchive/libarchive/archive_write_disk_posix.c +++ b/contrib/libarchive/libarchive/archive_write_disk_posix.c @@ -110,6 +110,18 @@ __FBSDID("$FreeBSD$"); #include #endif +/* + * Macro to cast st_mtime and time_t to an int64 so that 2 numbers can reliably be compared. + * + * It assumes that the input is an integer type of no more than 64 bits. + * If the number is less than zero, t must be a signed type, so it fits in + * int64_t. Otherwise, it's a nonnegative value so we can cast it to uint64_t + * without loss. But it could be a large unsigned value, so we have to clip it + * to INT64_MAX.* + */ +#define to_int64_time(t) \ + ((t) < 0 ? (int64_t)(t) : (uint64_t)(t) > (uint64_t)INT64_MAX ? INT64_MAX : (int64_t)(t)) + #if __APPLE__ #include #if TARGET_OS_MAC && !TARGET_OS_EMBEDDED && HAVE_QUARANTINE_H @@ -308,7 +320,7 @@ struct archive_write_disk { #define MAXIMUM_DIR_MODE 0775 /* - * Maxinum uncompressed size of a decmpfs block. + * Maximum uncompressed size of a decmpfs block. */ #define MAX_DECMPFS_BLOCK_SIZE (64 * 1024) /* @@ -323,7 +335,7 @@ struct archive_write_disk { #define RSRC_F_SIZE 50 /* Size of Resource fork footer. */ /* Size to write compressed data to resource fork. */ #define COMPRESSED_W_SIZE (64 * 1024) -/* decmpfs difinitions. */ +/* decmpfs definitions. */ #define MAX_DECMPFS_XATTR_SIZE 3802 #ifndef DECMPFS_XATTR_NAME #define DECMPFS_XATTR_NAME "com.apple.decmpfs" @@ -632,9 +644,9 @@ _archive_write_disk_header(struct archive *_a, struct archive_entry *entry) /* * NOTE: UF_COMPRESSED is ignored even if the filesystem * supports HFS+ Compression because the file should - * have at least an extended attriute "com.apple.decmpfs" + * have at least an extended attribute "com.apple.decmpfs" * before the flag is set to indicate that the file have - * been compressed. If hte filesystem does not support + * been compressed. If the filesystem does not support * HFS+ Compression the system call will fail. */ if (a->fd < 0 || fchflags(a->fd, UF_COMPRESSED) != 0) @@ -1247,7 +1259,7 @@ hfs_drive_compressor(struct archive_write_disk *a, const char *buff, ret = hfs_write_compressed_data(a, bytes_used + rsrc_size); a->compressed_buffer_remaining = a->compressed_buffer_size; - /* If the compressed size is not enouph smaller than + /* If the compressed size is not enough smaller than * the uncompressed size. cancel HFS+ compression. * TODO: study a behavior of ditto utility and improve * the condition to fall back into no HFS+ compression. */ @@ -1352,7 +1364,7 @@ hfs_write_decmpfs_block(struct archive_write_disk *a, const char *buff, (uint32_t *)(a->resource_fork + RSRC_H_SIZE); /* Set the block count to the resource fork. */ archive_le32enc(a->decmpfs_block_info++, block_count); - /* Get the position where we are goint to set compressed + /* Get the position where we are going to set compressed * data. */ a->compressed_rsrc_position = RSRC_H_SIZE + 4 + (block_count * 8); @@ -1425,7 +1437,7 @@ hfs_write_data_block(struct archive_write_disk *a, const char *buff, bytes_to_write = size; /* Seek if necessary to the specified offset. */ if (a->offset < a->fd_offset) { - /* Can't support backword move. */ + /* Can't support backward move. */ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Seek failed"); return (ARCHIVE_FATAL); @@ -1690,10 +1702,25 @@ _archive_write_disk_finish_entry(struct archive *_a) * ACLs that prevent attribute changes (including time). */ if (a->todo & TODO_ACLS) { - int r2 = archive_write_disk_set_acls(&a->archive, a->fd, - archive_entry_pathname(a->entry), - archive_entry_acl(a->entry)); + int r2; +#ifdef HAVE_DARWIN_ACL + /* + * On Mac OS, platform ACLs are stored also in mac_metadata by + * the operating system. If mac_metadata is present it takes + * precedence and we skip extracting libarchive NFSv4 ACLs + */ + const void *metadata; + size_t metadata_size; + metadata = archive_entry_mac_metadata(a->entry, &metadata_size); + if (metadata == NULL || metadata_size == 0) { +#endif + r2 = archive_write_disk_set_acls(&a->archive, a->fd, + archive_entry_pathname(a->entry), + archive_entry_acl(a->entry)); if (r2 < ret) ret = r2; +#ifdef HAVE_DARWIN_ACL + } +#endif } finish_metadata: @@ -2065,6 +2092,7 @@ create_filesystem_object(struct archive_write_disk *a) archive_set_error(&a->archive, error_number, "%s", error_string.s); free(linkname_copy); + archive_string_free(&error_string); /* * EPERM is more appropriate than error_number for our * callers @@ -2077,6 +2105,7 @@ create_filesystem_object(struct archive_write_disk *a) archive_set_error(&a->archive, error_number, "%s", error_string.s); free(linkname_copy); + archive_string_free(&error_string); /* * EPERM is more appropriate than error_number for our * callers @@ -2084,6 +2113,7 @@ create_filesystem_object(struct archive_write_disk *a) return (EPERM); } free(linkname_copy); + archive_string_free(&error_string); r = link(linkname, a->name) ? errno : 0; /* * New cpio and pax formats allow hardlink entries @@ -2252,8 +2282,12 @@ _archive_write_disk_close(struct archive *_a) if (p->fixup & TODO_MODE_BASE) chmod(p->name, p->mode); if (p->fixup & TODO_ACLS) - archive_write_disk_set_acls(&a->archive, - -1, p->name, &p->acl); +#ifdef HAVE_DARWIN_ACL + if (p->mac_metadata == NULL || + p->mac_metadata_size == 0) +#endif + archive_write_disk_set_acls(&a->archive, + -1, p->name, &p->acl); if (p->fixup & TODO_FFLAGS) set_fflags_platform(a, -1, p->name, p->mode, p->fflags_set, 0); @@ -4125,10 +4159,10 @@ older(struct stat *st, struct archive_entry *entry) { /* First, test the seconds and return if we have a definite answer. */ /* Definitely older. */ - if (st->st_mtime < archive_entry_mtime(entry)) + if (to_int64_time(st->st_mtime) < to_int64_time(archive_entry_mtime(entry))) return (1); /* Definitely younger. */ - if (st->st_mtime > archive_entry_mtime(entry)) + if (to_int64_time(st->st_mtime) > to_int64_time(archive_entry_mtime(entry))) return (0); /* If this platform supports fractional seconds, try those. */ #if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC diff --git a/contrib/libarchive/libarchive/archive_write_open.3 b/contrib/libarchive/libarchive/archive_write_open.3 index a52959b..457873e 100644 --- a/contrib/libarchive/libarchive/archive_write_open.3 +++ b/contrib/libarchive/libarchive/archive_write_open.3 @@ -66,6 +66,7 @@ Freeze the settings, open the archive, and prepare for writing entries. This is the most generic form of this function, which accepts pointers to three callback functions which will be invoked by the compression layer to write the constructed archive. +This does not alter the default archive padding. .It Fn archive_write_open_fd A convenience form of .Fn archive_write_open @@ -123,12 +124,21 @@ is currently in use. You should be careful to ensure that this variable remains allocated until after the archive is closed. +This function will disable padding unless you +have specifically set the block size. .El More information about the .Va struct archive object and the overall design of the library can be found in the .Xr libarchive 3 overview. +.Pp +Note that the convenience forms above vary in how +they block the output. +See +.Xr archive_write_blocksize 3 +if you need to control the block size used for writes +or the end-of-file padding behavior. .\" .Sh CLIENT CALLBACKS To use this library, you will need to define and register @@ -226,6 +236,7 @@ functions. .Xr tar 1 , .Xr libarchive 3 , .Xr archive_write 3 , +.Xr archive_write_blocksize 3 , .Xr archive_write_filter 3 , .Xr archive_write_format 3 , .Xr archive_write_new 3 , diff --git a/contrib/libarchive/libarchive/archive_write_set_format_7zip.c b/contrib/libarchive/libarchive/archive_write_set_format_7zip.c index abd521a..41ed74d 100644 --- a/contrib/libarchive/libarchive/archive_write_set_format_7zip.c +++ b/contrib/libarchive/libarchive/archive_write_set_format_7zip.c @@ -1358,7 +1358,7 @@ make_header(struct archive_write *a, uint64_t offset, uint64_t pack_size, if (r < 0) return (r); - /* Write Nume size. */ + /* Write Name size. */ r = enc_uint64(a, zip->total_bytes_entry_name+1); if (r < 0) return (r); diff --git a/contrib/libarchive/libarchive/archive_write_set_format_gnutar.c b/contrib/libarchive/libarchive/archive_write_set_format_gnutar.c index a9c4123..2d858c9 100644 --- a/contrib/libarchive/libarchive/archive_write_set_format_gnutar.c +++ b/contrib/libarchive/libarchive/archive_write_set_format_gnutar.c @@ -478,15 +478,15 @@ archive_write_gnutar_header(struct archive_write *a, archive_entry_set_pathname(temp, "././@LongLink"); archive_entry_set_size(temp, length); ret = archive_format_gnutar_header(a, buff, temp, 'K'); + archive_entry_free(temp); if (ret < ARCHIVE_WARN) goto exit_write_header; ret = __archive_write_output(a, buff, 512); - if(ret < ARCHIVE_WARN) + if (ret < ARCHIVE_WARN) goto exit_write_header; - archive_entry_free(temp); /* Write name and trailing null byte. */ ret = __archive_write_output(a, gnutar->linkname, length); - if(ret < ARCHIVE_WARN) + if (ret < ARCHIVE_WARN) goto exit_write_header; /* Pad to 512 bytes */ ret = __archive_write_nulls(a, 0x1ff & (-(ssize_t)length)); @@ -508,12 +508,12 @@ archive_write_gnutar_header(struct archive_write *a, archive_entry_set_pathname(temp, "././@LongLink"); archive_entry_set_size(temp, length); ret = archive_format_gnutar_header(a, buff, temp, 'L'); + archive_entry_free(temp); if (ret < ARCHIVE_WARN) goto exit_write_header; ret = __archive_write_output(a, buff, 512); if(ret < ARCHIVE_WARN) goto exit_write_header; - archive_entry_free(temp); /* Write pathname + trailing null byte. */ ret = __archive_write_output(a, pathname, length); if(ret < ARCHIVE_WARN) diff --git a/contrib/libarchive/libarchive/archive_write_set_format_iso9660.c b/contrib/libarchive/libarchive/archive_write_set_format_iso9660.c index bf69c3e..4e91097 100644 --- a/contrib/libarchive/libarchive/archive_write_set_format_iso9660.c +++ b/contrib/libarchive/libarchive/archive_write_set_format_iso9660.c @@ -161,7 +161,7 @@ struct isofile { /* Used for managing struct isofile list. */ struct isofile *allnext; struct isofile *datanext; - /* Used for managing a hardlined struct isofile list. */ + /* Used for managing a hardlinked struct isofile list. */ struct isofile *hlnext; struct isofile *hardlink_target; @@ -528,7 +528,7 @@ struct iso_option { * - allow more then 8 depths of directory trees; * - disable a version number to a File Name; * - disable a forced period to the tail of a File Name; - * - the maxinum length of files and directories is raised to 193. + * - the maximum length of files and directories is raised to 193. * if rockridge option is disabled, raised to 207. */ unsigned int iso_level:3; @@ -626,7 +626,7 @@ struct iso_option { * : NOTE Our rockridge=useful option does not set a zero * : to uid and gid, you should use application * : option such as --gid,--gname,--uid and --uname - * : badtar options instead. + * : bsdtar options instead. * Type : boolean/string * Default: Enabled as rockridge=useful * COMPAT : mkisofs -r / -R @@ -660,7 +660,7 @@ struct iso_option { * : for making zisofs. * : When the file size is less than one Logical Block * : size, that file will not zisofs'ed since it does - * : reduece an ISO-image size. + * : reduce an ISO-image size. * : * : When you specify option 'boot=', that * : 'boot-image' file won't be converted to zisofs file. @@ -703,7 +703,7 @@ struct iso9660 { } all_file_list; /* A list of struct isofile entries which have its - * contents and are not a directory, a hardlined file + * contents and are not a directory, a hardlinked file * and a symlink file. */ struct { struct isofile *first; @@ -1907,9 +1907,9 @@ iso9660_close(struct archive_write *a) iso9660->primary.rootent); if (ret < 0) return (ret); - /* Make sure we have UTF-16BE convertors. - * if there is no file entry, convertors are still - * uninitilized. */ + /* Make sure we have UTF-16BE converters. + * if there is no file entry, converters are still + * uninitialized. */ if (iso9660->sconv_to_utf16be == NULL) { iso9660->sconv_to_utf16be = archive_string_conversion_to_charset( @@ -2524,7 +2524,8 @@ get_tmfromtime(struct tm *tm, time_t *t) tzset(); localtime_r(t, tm); #elif HAVE__LOCALTIME64_S - _localtime64_s(tm, t); + __time64_t tmp_t = (__time64_t) *t; //time_t may be shorter than 64 bits + _localtime64_s(tm, &tmp_t); #else memcpy(tm, localtime(t), sizeof(*tm)); #endif @@ -2553,7 +2554,7 @@ set_date_time(unsigned char *p, time_t t) static void set_date_time_null(unsigned char *p) { - memset(p, '0', 16); + memset(p, (int)'0', 16); p[16] = 0; } @@ -2959,7 +2960,7 @@ set_directory_record_rr(unsigned char *bp, int dr_len, gid = archive_entry_gid(file->entry); if (iso9660->opt.rr == OPT_RR_USEFUL) { /* - * This action is simular mkisofs -r option + * This action is similar to mkisofs -r option * but our rockridge=useful option does not * set a zero to uid and gid. */ @@ -3108,7 +3109,7 @@ set_directory_record_rr(unsigned char *bp, int dr_len, /* * flg len * +----+----+ - * | 02 | 00 | CURREENT component. + * | 02 | 00 | CURRENT component. * +----+----+ (".") */ if (nc != NULL) { @@ -3947,7 +3948,7 @@ write_VD(struct archive_write *a, struct vdd *vdd) "Abstract File", 0, D_CHAR); if (r != ARCHIVE_OK) return (r); - /* Bibliongraphic File Identifier */ + /* Bibliographic File Identifier */ r = set_file_identifier(bp, 777, 813, vdc, a, vdd, &(iso9660->bibliographic_file_identifier), "Bibliongraphic File", 0, D_CHAR); @@ -4073,7 +4074,8 @@ write_information_block(struct archive_write *a) memset(info.s, 0, info_size); opt = 0; #if defined(HAVE__CTIME64_S) - _ctime64_s(buf, sizeof(buf), &(iso9660->birth_time)); + __time64_t iso9660_birth_time_tmp = (__time64_t) iso9660->birth_time; //time_t may be shorter than 64 bits + _ctime64_s(buf, sizeof(buf), &(iso9660_birth_time_tmp)); #elif defined(HAVE_CTIME_R) ctime_r(&(iso9660->birth_time), buf); #else @@ -6135,7 +6137,7 @@ isoent_gen_iso9660_identifier(struct archive_write *a, struct isoent *isoent, off = ffmax - extlen; if (off == 0) { /* A dot('.') character - * does't place to the first + * doesn't place to the first * byte of identifier. */ off ++; extlen --; @@ -7149,7 +7151,7 @@ isoent_create_boot_catalog(struct archive_write *a, struct isoent *rootent) iso9660->el_torito.catalog = isoent; /* - * Get a boot medai type. + * Get a boot media type. */ switch (iso9660->opt.boot_type) { default: diff --git a/contrib/libarchive/libarchive/archive_write_set_format_pax.c b/contrib/libarchive/libarchive/archive_write_set_format_pax.c index 786eec4..1a245d7 100644 --- a/contrib/libarchive/libarchive/archive_write_set_format_pax.c +++ b/contrib/libarchive/libarchive/archive_write_set_format_pax.c @@ -1,6 +1,7 @@ /*- * Copyright (c) 2003-2007 Tim Kientzle * Copyright (c) 2010-2012 Michihiro NAKAJIMA + * Copyright (c) 2016 Martin Matuska * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -61,15 +62,24 @@ struct pax { struct sparse_block *sparse_tail; struct archive_string_conv *sconv_utf8; int opt_binary; + + unsigned flags; +#define WRITE_SCHILY_XATTR (1 << 0) +#define WRITE_LIBARCHIVE_XATTR (1 << 1) }; static void add_pax_attr(struct archive_string *, const char *key, const char *value); +static void add_pax_attr_binary(struct archive_string *, + const char *key, + const char *value, size_t value_len); static void add_pax_attr_int(struct archive_string *, const char *key, int64_t value); static void add_pax_attr_time(struct archive_string *, const char *key, int64_t sec, unsigned long nanos); +static int add_pax_acl(struct archive_write *, + struct archive_entry *, struct pax *, int); static ssize_t archive_write_pax_data(struct archive_write *, const void *, size_t); static int archive_write_pax_close(struct archive_write *); @@ -133,6 +143,8 @@ archive_write_set_format_pax(struct archive *_a) "Can't allocate pax data"); return (ARCHIVE_FATAL); } + pax->flags = WRITE_LIBARCHIVE_XATTR | WRITE_SCHILY_XATTR; + a->format_data = pax; a->format_name = "pax"; a->format_options = archive_write_pax_options; @@ -272,6 +284,17 @@ add_pax_attr_int(struct archive_string *as, const char *key, int64_t value) static void add_pax_attr(struct archive_string *as, const char *key, const char *value) { + add_pax_attr_binary(as, key, value, strlen(value)); +} + +/* + * Add a key/value attribute to the pax header. This function handles + * binary values. + */ +static void +add_pax_attr_binary(struct archive_string *as, const char *key, + const char *value, size_t value_len) +{ int digits, i, len, next_ten; char tmp[1 + 3 * sizeof(int)]; /* < 3 base-10 digits per byte */ @@ -279,7 +302,7 @@ add_pax_attr(struct archive_string *as, const char *key, const char *value) * PAX attributes have the following layout: * <=> */ - len = 1 + (int)strlen(key) + 1 + (int)strlen(value) + 1; + len = 1 + (int)strlen(key) + 1 + (int)value_len + 1; /* * The field includes the length of the field, so @@ -310,21 +333,47 @@ add_pax_attr(struct archive_string *as, const char *key, const char *value) archive_strappend_char(as, ' '); archive_strcat(as, key); archive_strappend_char(as, '='); - archive_strcat(as, value); + archive_array_append(as, value, value_len); archive_strappend_char(as, '\n'); } +static void +archive_write_pax_header_xattr(struct pax *pax, const char *encoded_name, + const void *value, size_t value_len) +{ + struct archive_string s; + char *encoded_value; + + if (pax->flags & WRITE_LIBARCHIVE_XATTR) { + encoded_value = base64_encode((const char *)value, value_len); + + if (encoded_name != NULL && encoded_value != NULL) { + archive_string_init(&s); + archive_strcpy(&s, "LIBARCHIVE.xattr."); + archive_strcat(&s, encoded_name); + add_pax_attr(&(pax->pax_header), s.s, encoded_value); + archive_string_free(&s); + } + free(encoded_value); + } + if (pax->flags & WRITE_SCHILY_XATTR) { + archive_string_init(&s); + archive_strcpy(&s, "SCHILY.xattr."); + archive_strcat(&s, encoded_name); + add_pax_attr_binary(&(pax->pax_header), s.s, value, value_len); + archive_string_free(&s); + } +} + static int archive_write_pax_header_xattrs(struct archive_write *a, struct pax *pax, struct archive_entry *entry) { - struct archive_string s; int i = archive_entry_xattr_reset(entry); while (i--) { const char *name; const void *value; - char *encoded_value; char *url_encoded_name = NULL, *encoded_name = NULL; size_t size; int r; @@ -345,16 +394,9 @@ archive_write_pax_header_xattrs(struct archive_write *a, } } - encoded_value = base64_encode((const char *)value, size); + archive_write_pax_header_xattr(pax, encoded_name, + value, size); - if (encoded_name != NULL && encoded_value != NULL) { - archive_string_init(&s); - archive_strcpy(&s, "LIBARCHIVE.xattr."); - archive_strcat(&s, encoded_name); - add_pax_attr(&(pax->pax_header), s.s, encoded_value); - archive_string_free(&s); - } - free(encoded_value); } return (ARCHIVE_OK); } @@ -449,6 +491,45 @@ get_entry_symlink(struct archive_write *a, struct archive_entry *entry, return (ARCHIVE_OK); } +/* Add ACL to pax header */ +static int +add_pax_acl(struct archive_write *a, + struct archive_entry *entry, struct pax *pax, int flags) +{ + char *p; + const char *attr; + int acl_types; + + acl_types = archive_entry_acl_types(entry); + + if ((acl_types & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) + attr = "SCHILY.acl.ace"; + else if ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) + attr = "SCHILY.acl.access"; + else if ((flags & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) + attr = "SCHILY.acl.default"; + else + return (ARCHIVE_FATAL); + + p = archive_entry_acl_to_text_l(entry, NULL, flags, pax->sconv_utf8); + if (p == NULL) { + if (errno == ENOMEM) { + archive_set_error(&a->archive, ENOMEM, "%s %s", + "Can't allocate memory for ", attr); + return (ARCHIVE_FATAL); + } + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, "%s %s %s", + "Can't translate ", attr, " to UTF-8"); + return(ARCHIVE_WARN); + } else if (*p != '\0') { + add_pax_attr(&(pax->pax_header), + attr, p); + free(p); + } + return(ARCHIVE_OK); +} + /* * TODO: Consider adding 'comment' and 'charset' fields to * archive_entry so that clients can specify them. Also, consider @@ -465,6 +546,7 @@ archive_write_pax_header(struct archive_write *a, const char *p; const char *suffix; int need_extension, r, ret; + int acl_types; int sparse_count; uint64_t sparse_total, real_size; struct pax *pax; @@ -1016,16 +1098,6 @@ archive_write_pax_header(struct archive_write *a, if (!need_extension && p != NULL && *p != '\0') need_extension = 1; - /* If there are non-trivial ACL entries, we need an extension. */ - if (!need_extension && archive_entry_acl_count(entry_original, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS) > 0) - need_extension = 1; - - /* If there are non-trivial ACL entries, we need an extension. */ - if (!need_extension && archive_entry_acl_count(entry_original, - ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) > 0) - need_extension = 1; - /* If there are extended attributes, we need an extension */ if (!need_extension && archive_entry_xattr_count(entry_original) > 0) need_extension = 1; @@ -1034,6 +1106,12 @@ archive_write_pax_header(struct archive_write *a, if (!need_extension && sparse_count > 0) need_extension = 1; + acl_types = archive_entry_acl_types(entry_original); + + /* If there are any ACL entries, we need an extension */ + if (!need_extension && acl_types != 0) + need_extension = 1; + /* * Libarchive used to include these in extended headers for * restricted pax format, but that confused people who @@ -1085,43 +1163,28 @@ archive_write_pax_header(struct archive_write *a, add_pax_attr(&(pax->pax_header), "SCHILY.fflags", p); /* I use star-compatible ACL attributes. */ - r = archive_entry_acl_text_l(entry_original, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS | - ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID, - &p, NULL, pax->sconv_utf8); - if (r != 0) { - if (errno == ENOMEM) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate memory for " - "ACL.access"); + if ((acl_types & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) { + ret = add_pax_acl(a, entry_original, pax, + ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID | + ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA); + if (ret == ARCHIVE_FATAL) return (ARCHIVE_FATAL); - } - archive_set_error(&a->archive, - ARCHIVE_ERRNO_FILE_FORMAT, - "Can't translate ACL.access to UTF-8"); - ret = ARCHIVE_WARN; - } else if (p != NULL && *p != '\0') { - add_pax_attr(&(pax->pax_header), - "SCHILY.acl.access", p); } - r = archive_entry_acl_text_l(entry_original, - ARCHIVE_ENTRY_ACL_TYPE_DEFAULT | - ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID, - &p, NULL, pax->sconv_utf8); - if (r != 0) { - if (errno == ENOMEM) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate memory for " - "ACL.default"); + if (acl_types & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) { + ret = add_pax_acl(a, entry_original, pax, + ARCHIVE_ENTRY_ACL_TYPE_ACCESS | + ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID | + ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA); + if (ret == ARCHIVE_FATAL) + return (ARCHIVE_FATAL); + } + if (acl_types & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) { + ret = add_pax_acl(a, entry_original, pax, + ARCHIVE_ENTRY_ACL_TYPE_DEFAULT | + ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID | + ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA); + if (ret == ARCHIVE_FATAL) return (ARCHIVE_FATAL); - } - archive_set_error(&a->archive, - ARCHIVE_ERRNO_FILE_FORMAT, - "Can't translate ACL.default to UTF-8"); - ret = ARCHIVE_WARN; - } else if (p != NULL && *p != '\0') { - add_pax_attr(&(pax->pax_header), - "SCHILY.acl.default", p); } /* We use GNU-tar-compatible sparse attributes. */ diff --git a/contrib/libarchive/libarchive/archive_write_set_format_warc.c b/contrib/libarchive/libarchive/archive_write_set_format_warc.c index ea66929..8b6daf9 100644 --- a/contrib/libarchive/libarchive/archive_write_set_format_warc.c +++ b/contrib/libarchive/libarchive/archive_write_set_format_warc.c @@ -79,7 +79,7 @@ typedef enum { WT_RVIS, /* conversion, unsupported */ WT_CONV, - /* continutation, unsupported at the moment */ + /* continuation, unsupported at the moment */ WT_CONT, /* invalid type */ LAST_WT diff --git a/contrib/libarchive/libarchive/archive_write_set_format_xar.c b/contrib/libarchive/libarchive/archive_write_set_format_xar.c index da6daac..495f0d4 100644 --- a/contrib/libarchive/libarchive/archive_write_set_format_xar.c +++ b/contrib/libarchive/libarchive/archive_write_set_format_xar.c @@ -63,7 +63,7 @@ __FBSDID("$FreeBSD$"); * - When writing an XML element , * which is a file type a symbolic link is referencing is always marked * as "broken". Xar utility uses stat(2) to get the file type, but, in - * libarcive format writer, we should not use it; if it is needed, we + * libarchive format writer, we should not use it; if it is needed, we * should get about it at archive_read_disk.c. * - It is possible to appear both and elements. * Xar utility generates on BSD platform and on Linux @@ -1227,7 +1227,7 @@ make_file_entry(struct archive_write *a, xmlTextWriterPtr writer, case AE_IFLNK: /* * xar utility has checked a file type, which - * a symblic-link file has referenced. + * a symbolic-link file has referenced. * For example: * ../ref/ * The symlink target file is "../ref/" and its @@ -1237,8 +1237,8 @@ make_file_entry(struct archive_write *a, xmlTextWriterPtr writer, * The symlink target file is "../f" and its * file type is a regular file. * - * But our implemention cannot do it, and then we - * always record that a attribute "type" is "borken", + * But our implementation cannot do it, and then we + * always record that a attribute "type" is "broken", * for example: * foo/bar * It means "foo/bar" is not reachable. @@ -1544,7 +1544,7 @@ make_toc(struct archive_write *a) } /* - * Start recoding TOC + * Start recording TOC */ r = xmlTextWriterStartElement(writer, BAD_CAST("xar")); if (r < 0) { @@ -1961,6 +1961,7 @@ file_free(struct file *file) archive_string_free(&(file->basename)); archive_string_free(&(file->symlink)); archive_string_free(&(file->script)); + archive_entry_free(file->entry); free(file); } @@ -2484,7 +2485,7 @@ file_connect_hardlink_files(struct xar *xar) archive_entry_set_nlink(target->entry, hl->nlink); if (hl->nlink > 1) /* It means this file is a hardlink - * targe itself. */ + * target itself. */ target->hardlink_target = target; for (nf = target->hlnext; nf != NULL; nf = nf->hlnext) { @@ -2913,7 +2914,7 @@ compression_init_encoder_xz(struct archive *a, *strm = lzma_init_data; #ifdef HAVE_LZMA_STREAM_ENCODER_MT if (threads > 1) { - bzero(&mt_options, sizeof(mt_options)); + memset(&mt_options, 0, sizeof(mt_options)); mt_options.threads = threads; mt_options.timeout = 300; mt_options.filters = lzmafilters; diff --git a/contrib/libarchive/libarchive/archive_write_set_format_zip.c b/contrib/libarchive/libarchive/archive_write_set_format_zip.c index a69ce20..38a9abf 100644 --- a/contrib/libarchive/libarchive/archive_write_set_format_zip.c +++ b/contrib/libarchive/libarchive/archive_write_set_format_zip.c @@ -878,7 +878,7 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) || zip->entry_encryption == ENCRYPTION_WINZIP_AES256)) { memcpy(e, "\001\231\007\000\001\000AE", 8); - /* AES vendoer version AE-2 does not store a CRC. + /* AES vendor version AE-2 does not store a CRC. * WinZip 11 uses AE-1, which does store the CRC, * but it does not store the CRC when the file size * is less than 20 bytes. So we simulate what @@ -1013,7 +1013,7 @@ archive_write_zip_data(struct archive_write *a, const void *buff, size_t s) if (zip->entry_flags & ZIP_ENTRY_FLAG_ENCRYPTED) { switch (zip->entry_encryption) { case ENCRYPTION_TRADITIONAL: - /* Initialize traditoinal PKWARE encryption context. */ + /* Initialize traditional PKWARE encryption context. */ if (!zip->tctx_valid) { ret = init_traditional_pkware_encryption(a); if (ret != ARCHIVE_OK) @@ -1499,7 +1499,7 @@ trad_enc_update_keys(struct trad_enc_ctx *ctx, uint8_t c) } static uint8_t -trad_enc_decypt_byte(struct trad_enc_ctx *ctx) +trad_enc_decrypt_byte(struct trad_enc_ctx *ctx) { unsigned temp = ctx->keys[2] | 2; return (uint8_t)((temp * (temp ^ 1)) >> 8) & 0xff; @@ -1515,7 +1515,7 @@ trad_enc_encrypt_update(struct trad_enc_ctx *ctx, const uint8_t *in, for (i = 0; i < max; i++) { uint8_t t = in[i]; - out[i] = t ^ trad_enc_decypt_byte(ctx); + out[i] = t ^ trad_enc_decrypt_byte(ctx); trad_enc_update_keys(ctx, t); } return i; @@ -1626,7 +1626,7 @@ init_winzip_aes_encryption(struct archive_write *a) return (ARCHIVE_FAILED); } - /* Set a passowrd verification value after the 'salt'. */ + /* Set a password verification value after the 'salt'. */ salt[salt_len] = derived_key[key_len * 2]; salt[salt_len + 1] = derived_key[key_len * 2 + 1]; diff --git a/contrib/libarchive/libarchive/libarchive-formats.5 b/contrib/libarchive/libarchive/libarchive-formats.5 index 9cec760..62359dd 100644 --- a/contrib/libarchive/libarchive/libarchive-formats.5 +++ b/contrib/libarchive/libarchive/libarchive-formats.5 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 18, 2012 +.Dd December 27, 2016 .Dt LIBARCHIVE-FORMATS 5 .Os .Sh NAME @@ -191,8 +191,6 @@ and device numbers. .It Solaris extensions Libarchive recognizes ACL and extended attribute records written by Solaris tar. -Currently, libarchive only has support for old-style ACLs; the -newer NFSv4 ACLs are recognized but discarded. .El .Pp The first tar program appeared in Seventh Edition Unix in 1979. diff --git a/contrib/libarchive/libarchive/tar.5 b/contrib/libarchive/libarchive/tar.5 index 6e6f0c0..30b837dc 100644 --- a/contrib/libarchive/libarchive/tar.5 +++ b/contrib/libarchive/libarchive/tar.5 @@ -1,4 +1,5 @@ .\" Copyright (c) 2003-2009 Tim Kientzle +.\" Copyright (c) 2016 Martin Matuska .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -24,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 23, 2011 +.Dd December 27, 2016 .Dt TAR 5 .Os .Sh NAME @@ -440,11 +441,11 @@ archives to store files much larger than the historic 8GB limit. Vendor-specific attributes used by Joerg Schilling's .Nm star implementation. -.It Cm SCHILY.acl.access , Cm SCHILY.acl.default -Stores the access and default ACLs as textual strings in a format +.It Cm SCHILY.acl.access , Cm SCHILY.acl.default, Cm SCHILY.acl.ace +Stores the access, default and NFSv4 ACLs as textual strings in a format that is an extension of the format specified by POSIX.1e draft 17. -In particular, each user or group access specification can include a fourth -colon-separated field with the numeric UID or GID. +In particular, each user or group access specification can include +an additional colon-separated field with the numeric UID or GID. This allows ACLs to be restored on systems that may not have complete user or group information available (such as when NIS/YP or LDAP services are temporarily unavailable). diff --git a/contrib/libarchive/libarchive/test/main.c b/contrib/libarchive/libarchive/test/main.c index 4f3cdac..d75f1ab 100644 --- a/contrib/libarchive/libarchive/test/main.c +++ b/contrib/libarchive/libarchive/test/main.c @@ -216,6 +216,12 @@ invalid_parameter_handler(const wchar_t * expression, unsigned int line, uintptr_t pReserved) { /* nop */ + // Silence unused-parameter compiler warnings. + (void)expression; + (void)function; + (void)file; + (void)line; + (void)pReserved; } #endif @@ -1412,6 +1418,8 @@ assertion_file_mode(const char *file, int line, const char *pathname, int expect failure_start(file, line, "assertFileMode not yet implemented for Windows"); (void)mode; /* UNUSED */ (void)r; /* UNUSED */ + (void)pathname; /* UNUSED */ + (void)expected_mode; /* UNUSED */ #else { struct stat st; @@ -2421,6 +2429,132 @@ extract_reference_files(const char **names) extract_reference_file(*names++); } +/* Set ACLs */ +void +archive_test_set_acls(struct archive_entry *ae, + struct archive_test_acl_t *acls, int n) +{ + int i; + + archive_entry_acl_clear(ae); + for (i = 0; i < n; i++) { + failure("type=%#010x, permset=%#010x, tag=%d, qual=%d name=%s", + acls[i].type, acls[i].permset, acls[i].tag, + acls[i].qual, acls[i].name); + assertEqualInt(ARCHIVE_OK, + archive_entry_acl_add_entry(ae, + acls[i].type, acls[i].permset, acls[i].tag, + acls[i].qual, acls[i].name)); + } +} + +static int +archive_test_acl_match(struct archive_test_acl_t *acl, int type, int permset, + int tag, int qual, const char *name) +{ + if (type != acl->type) + return (0); + if (permset != acl->permset) + return (0); + if (tag != acl->tag) + return (0); + if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) + return (1); + if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) + return (1); + if (tag == ARCHIVE_ENTRY_ACL_EVERYONE) + return (1); + if (tag == ARCHIVE_ENTRY_ACL_OTHER) + return (1); + if (qual != acl->qual) + return (0); + if (name == NULL) { + if (acl->name == NULL || acl->name[0] == '\0') + return (1); + return (0); + } + if (acl->name == NULL) { + if (name[0] == '\0') + return (1); + return (0); + } + return (0 == strcmp(name, acl->name)); +} + +/* Compare ACLs */ +void +archive_test_compare_acls(struct archive_entry *ae, + struct archive_test_acl_t *acls, int cnt, int want_type, int mode) +{ + int *marker; + int i, r, n; + int type, permset, tag, qual; + int matched; + const char *name; + + n = 0; + marker = malloc(sizeof(marker[0]) * cnt); + + for (i = 0; i < cnt; i++) { + if ((acls[i].type & want_type) != 0) { + marker[n] = i; + n++; + } + } + + failure("No ACL's to compare, type mask: %d", want_type); + assert(n > 0); + if (n == 0) + return; + + while (0 == (r = archive_entry_acl_next(ae, want_type, + &type, &permset, &tag, &qual, &name))) { + for (i = 0, matched = 0; i < n && !matched; i++) { + if (archive_test_acl_match(&acls[marker[i]], type, + permset, tag, qual, name)) { + /* We found a match; remove it. */ + marker[i] = marker[n - 1]; + n--; + matched = 1; + } + } + if (type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS + && tag == ARCHIVE_ENTRY_ACL_USER_OBJ) { + if (!matched) printf("No match for user_obj perm\n"); + failure("USER_OBJ permset (%02o) != user mode (%02o)", + permset, 07 & (mode >> 6)); + assert((permset << 6) == (mode & 0700)); + } else if (type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS + && tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) { + if (!matched) printf("No match for group_obj perm\n"); + failure("GROUP_OBJ permset %02o != group mode %02o", + permset, 07 & (mode >> 3)); + assert((permset << 3) == (mode & 0070)); + } else if (type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS + && tag == ARCHIVE_ENTRY_ACL_OTHER) { + if (!matched) printf("No match for other perm\n"); + failure("OTHER permset (%02o) != other mode (%02o)", + permset, mode & 07); + assert((permset << 0) == (mode & 0007)); + } else { + failure("Could not find match for ACL " + "(type=%#010x,permset=%#010x,tag=%d,qual=%d," + "name=``%s'')", type, permset, tag, qual, name); + assert(matched == 1); + } + } + assertEqualInt(ARCHIVE_EOF, r); + if ((want_type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) + assert((mode_t)(mode & 0777) == (archive_entry_mode(ae) + & 0777)); + failure("Could not find match for ACL " + "(type=%#010x,permset=%#010x,tag=%d,qual=%d,name=``%s'')", + acls[marker[0]].type, acls[marker[0]].permset, + acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name); + assert(n == 0); /* Number of ACLs not matched should == 0 */ + free(marker); +} + /* * * TEST management diff --git a/contrib/libarchive/libarchive/test/test.h b/contrib/libarchive/libarchive/test/test.h index f7ec59f..dc3f590 100644 --- a/contrib/libarchive/libarchive/test/test.h +++ b/contrib/libarchive/libarchive/test/test.h @@ -121,6 +121,32 @@ #endif /* + * If this platform has , acl_create(), acl_init(), + * acl_set_file(), and ACL_USER, we assume it has the rest of the + * POSIX.1e draft functions used in archive_read_extract.c. + */ +#if HAVE_SYS_ACL_H && HAVE_ACL_CREATE_ENTRY && HAVE_ACL_INIT && HAVE_ACL_SET_FILE +#if HAVE_ACL_USER +#define HAVE_POSIX_ACL 1 +#elif HAVE_ACL_TYPE_EXTENDED +#define HAVE_DARWIN_ACL 1 +#endif +#endif + +/* + * If this platform has , acl_get(), facl_get(), acl_set(), + * facl_set() and types aclent_t and ace_t it uses Solaris-style ACL functions + */ +#if HAVE_SYS_ACL_H && HAVE_ACL_GET && HAVE_FACL_GET && HAVE_ACL_SET && HAVE_FACL_SET && HAVE_ACLENT_T && HAVE_ACE_T +#define HAVE_SUN_ACL 1 +#endif + +/* Define if platform supports NFSv4 ACLs */ +#if (HAVE_POSIX_ACL && HAVE_ACL_TYPE_NFS4) || HAVE_SUN_ACL || HAVE_DARWIN_ACL +#define HAVE_NFS4_ACL 1 +#endif + +/* * Redefine DEFINE_TEST for use in defining the test functions. */ #undef DEFINE_TEST @@ -346,6 +372,23 @@ extern const char *testworkdir; #include "archive.h" #include "archive_entry.h" +/* ACL structure */ +struct archive_test_acl_t { + int type; /* Type of ACL */ + int permset; /* Permissions for this class of users. */ + int tag; /* Owner, User, Owning group, group, other, etc. */ + int qual; /* GID or UID of user/group, depending on tag. */ + const char *name; /* Name of user/group, depending on tag. */ +}; + +/* Set ACLs */ +void archive_test_set_acls(struct archive_entry *, struct archive_test_acl_t *, + int); + +/* Compare ACLs */ +void archive_test_compare_acls(struct archive_entry *, + struct archive_test_acl_t *, int, int, int); + /* Special customized read-from-memory interface. */ int read_open_memory(struct archive *, const void *, size_t, size_t); /* _minimal version exercises a slightly different set of libarchive APIs. */ diff --git a/contrib/libarchive/libarchive/test/test_acl_freebsd_nfs4.c b/contrib/libarchive/libarchive/test/test_acl_freebsd_nfs4.c deleted file mode 100644 index 89861d6..0000000 --- a/contrib/libarchive/libarchive/test/test_acl_freebsd_nfs4.c +++ /dev/null @@ -1,547 +0,0 @@ -/*- - * Copyright (c) 2003-2010 Tim Kientzle - * 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(S) ``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(S) 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. - */ -#include "test.h" -__FBSDID("$FreeBSD$"); - -#if defined(__FreeBSD__) && __FreeBSD__ >= 8 -#define _ACL_PRIVATE -#include - -struct myacl_t { - int type; - int permset; - int tag; - int qual; /* GID or UID of user/group, depending on tag. */ - const char *name; /* Name of user/group, depending on tag. */ -}; - -static struct myacl_t acls_reg[] = { - /* For this test, we need the file owner to be able to read and write the ACL. */ - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, - ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_READ_ACL | ARCHIVE_ENTRY_ACL_WRITE_ACL | ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, - ARCHIVE_ENTRY_ACL_USER_OBJ, -1, ""}, - - /* An entry for each type. */ - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_USER, 108, "user108" }, - { ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_USER, 109, "user109" }, - - /* An entry for each permission. */ - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_USER, 112, "user112" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_DATA, - ARCHIVE_ENTRY_ACL_USER, 113, "user113" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_DATA, - ARCHIVE_ENTRY_ACL_USER, 115, "user115" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_APPEND_DATA, - ARCHIVE_ENTRY_ACL_USER, 117, "user117" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, - ARCHIVE_ENTRY_ACL_USER, 119, "user119" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, - ARCHIVE_ENTRY_ACL_USER, 120, "user120" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, - ARCHIVE_ENTRY_ACL_USER, 122, "user122" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, - ARCHIVE_ENTRY_ACL_USER, 123, "user123" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_DELETE, - ARCHIVE_ENTRY_ACL_USER, 124, "user124" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_ACL, - ARCHIVE_ENTRY_ACL_USER, 125, "user125" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_ACL, - ARCHIVE_ENTRY_ACL_USER, 126, "user126" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_OWNER, - ARCHIVE_ENTRY_ACL_USER, 127, "user127" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_SYNCHRONIZE, - ARCHIVE_ENTRY_ACL_USER, 128, "user128" }, - - /* One entry for each qualifier. */ - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_USER, 135, "user135" }, -// { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE, -// ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_GROUP, 136, "group136" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_EVERYONE, -1, "" } -}; - - -static struct myacl_t acls_dir[] = { - /* For this test, we need to be able to read and write the ACL. */ - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_READ_ACL, - ARCHIVE_ENTRY_ACL_USER_OBJ, -1, ""}, - - /* An entry for each type. */ - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, - ARCHIVE_ENTRY_ACL_USER, 101, "user101" }, - { ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, - ARCHIVE_ENTRY_ACL_USER, 102, "user102" }, - - /* An entry for each permission. */ - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, - ARCHIVE_ENTRY_ACL_USER, 201, "user201" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_ADD_FILE, - ARCHIVE_ENTRY_ACL_USER, 202, "user202" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, - ARCHIVE_ENTRY_ACL_USER, 203, "user203" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, - ARCHIVE_ENTRY_ACL_USER, 204, "user204" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, - ARCHIVE_ENTRY_ACL_USER, 205, "user205" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_DELETE_CHILD, - ARCHIVE_ENTRY_ACL_USER, 206, "user206" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, - ARCHIVE_ENTRY_ACL_USER, 207, "user207" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, - ARCHIVE_ENTRY_ACL_USER, 208, "user208" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_DELETE, - ARCHIVE_ENTRY_ACL_USER, 209, "user209" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_ACL, - ARCHIVE_ENTRY_ACL_USER, 210, "user210" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_ACL, - ARCHIVE_ENTRY_ACL_USER, 211, "user211" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_OWNER, - ARCHIVE_ENTRY_ACL_USER, 212, "user212" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_SYNCHRONIZE, - ARCHIVE_ENTRY_ACL_USER, 213, "user213" }, - - /* One entry with each inheritance value. */ - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, - ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, - ARCHIVE_ENTRY_ACL_USER, 301, "user301" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, - ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, - ARCHIVE_ENTRY_ACL_USER, 302, "user302" }, -#if 0 - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, - ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, - ARCHIVE_ENTRY_ACL_USER, 303, "user303" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, - ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, - ARCHIVE_ENTRY_ACL_USER, 304, "user304" }, -#endif - -#if 0 - /* FreeBSD does not support audit entries. */ - { ARCHIVE_ENTRY_ACL_TYPE_AUDIT, - ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, - ARCHIVE_ENTRY_ACL_USER, 401, "user401" }, - { ARCHIVE_ENTRY_ACL_TYPE_AUDIT, - ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, - ARCHIVE_ENTRY_ACL_USER, 402, "user402" }, -#endif - - /* One entry for each qualifier. */ - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, - ARCHIVE_ENTRY_ACL_USER, 501, "user501" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, - ARCHIVE_ENTRY_ACL_GROUP, 502, "group502" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, - ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, - ARCHIVE_ENTRY_ACL_EVERYONE, -1, "" } -}; - -static void -set_acls(struct archive_entry *ae, struct myacl_t *acls, int start, int end) -{ - int i; - - archive_entry_acl_clear(ae); - if (start > 0) { - assertEqualInt(ARCHIVE_OK, - archive_entry_acl_add_entry(ae, - acls[0].type, acls[0].permset, acls[0].tag, - acls[0].qual, acls[0].name)); - } - for (i = start; i < end; i++) { - assertEqualInt(ARCHIVE_OK, - archive_entry_acl_add_entry(ae, - acls[i].type, acls[i].permset, acls[i].tag, - acls[i].qual, acls[i].name)); - } -} - -static int -acl_permset_to_bitmap(acl_permset_t opaque_ps) -{ - static struct { int machine; int portable; } perms[] = { - {ACL_EXECUTE, ARCHIVE_ENTRY_ACL_EXECUTE}, - {ACL_WRITE, ARCHIVE_ENTRY_ACL_WRITE}, - {ACL_READ, ARCHIVE_ENTRY_ACL_READ}, - {ACL_READ_DATA, ARCHIVE_ENTRY_ACL_READ_DATA}, - {ACL_LIST_DIRECTORY, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY}, - {ACL_WRITE_DATA, ARCHIVE_ENTRY_ACL_WRITE_DATA}, - {ACL_ADD_FILE, ARCHIVE_ENTRY_ACL_ADD_FILE}, - {ACL_APPEND_DATA, ARCHIVE_ENTRY_ACL_APPEND_DATA}, - {ACL_ADD_SUBDIRECTORY, ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY}, - {ACL_READ_NAMED_ATTRS, ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS}, - {ACL_WRITE_NAMED_ATTRS, ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS}, - {ACL_DELETE_CHILD, ARCHIVE_ENTRY_ACL_DELETE_CHILD}, - {ACL_READ_ATTRIBUTES, ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES}, - {ACL_WRITE_ATTRIBUTES, ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES}, - {ACL_DELETE, ARCHIVE_ENTRY_ACL_DELETE}, - {ACL_READ_ACL, ARCHIVE_ENTRY_ACL_READ_ACL}, - {ACL_WRITE_ACL, ARCHIVE_ENTRY_ACL_WRITE_ACL}, - {ACL_WRITE_OWNER, ARCHIVE_ENTRY_ACL_WRITE_OWNER}, - {ACL_SYNCHRONIZE, ARCHIVE_ENTRY_ACL_SYNCHRONIZE} - }; - int i, permset = 0; - - for (i = 0; i < (int)(sizeof(perms)/sizeof(perms[0])); ++i) - if (acl_get_perm_np(opaque_ps, perms[i].machine)) - permset |= perms[i].portable; - return permset; -} - -static int -acl_flagset_to_bitmap(acl_flagset_t opaque_fs) -{ - static struct { int machine; int portable; } flags[] = { - {ACL_ENTRY_FILE_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT}, - {ACL_ENTRY_DIRECTORY_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT}, - {ACL_ENTRY_NO_PROPAGATE_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT}, - {ACL_ENTRY_INHERIT_ONLY, ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY}, - }; - int i, flagset = 0; - - for (i = 0; i < (int)(sizeof(flags)/sizeof(flags[0])); ++i) - if (acl_get_flag_np(opaque_fs, flags[i].machine)) - flagset |= flags[i].portable; - return flagset; -} - -static int -acl_match(acl_entry_t aclent, struct myacl_t *myacl) -{ - gid_t g, *gp; - uid_t u, *up; - acl_tag_t tag_type; - acl_permset_t opaque_ps; - acl_flagset_t opaque_fs; - int perms; - - acl_get_tag_type(aclent, &tag_type); - - /* translate the silly opaque permset to a bitmap */ - acl_get_permset(aclent, &opaque_ps); - acl_get_flagset_np(aclent, &opaque_fs); - perms = acl_permset_to_bitmap(opaque_ps) | acl_flagset_to_bitmap(opaque_fs); - if (perms != myacl->permset) - return (0); - - switch (tag_type) { - case ACL_USER_OBJ: - if (myacl->tag != ARCHIVE_ENTRY_ACL_USER_OBJ) return (0); - break; - case ACL_USER: - if (myacl->tag != ARCHIVE_ENTRY_ACL_USER) - return (0); - up = acl_get_qualifier(aclent); - u = *up; - acl_free(up); - if ((uid_t)myacl->qual != u) - return (0); - break; - case ACL_GROUP_OBJ: - if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP_OBJ) return (0); - break; - case ACL_GROUP: - if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP) - return (0); - gp = acl_get_qualifier(aclent); - g = *gp; - acl_free(gp); - if ((gid_t)myacl->qual != g) - return (0); - break; - case ACL_MASK: - if (myacl->tag != ARCHIVE_ENTRY_ACL_MASK) return (0); - break; - case ACL_EVERYONE: - if (myacl->tag != ARCHIVE_ENTRY_ACL_EVERYONE) return (0); - break; - } - return (1); -} - -static void -compare_acls(acl_t acl, struct myacl_t *myacls, const char *filename, int start, int end) -{ - int *marker; - int entry_id = ACL_FIRST_ENTRY; - int matched; - int i, n; - acl_entry_t acl_entry; - - n = end - start; - marker = malloc(sizeof(marker[0]) * (n + 1)); - for (i = 0; i < n; i++) - marker[i] = i + start; - /* Always include the first ACE. */ - if (start > 0) { - marker[n] = 0; - ++n; - } - - /* - * Iterate over acls in system acl object, try to match each - * one with an item in the myacls array. - */ - while (1 == acl_get_entry(acl, entry_id, &acl_entry)) { - /* After the first time... */ - entry_id = ACL_NEXT_ENTRY; - - /* Search for a matching entry (tag and qualifier) */ - for (i = 0, matched = 0; i < n && !matched; i++) { - if (acl_match(acl_entry, &myacls[marker[i]])) { - /* We found a match; remove it. */ - marker[i] = marker[n - 1]; - n--; - matched = 1; - } - } - - failure("ACL entry on file %s that shouldn't be there", filename); - assert(matched == 1); - } - - /* Dump entries in the myacls array that weren't in the system acl. */ - for (i = 0; i < n; ++i) { - failure(" ACL entry %d missing from %s: " - "type=%d,permset=%x,tag=%d,qual=%d,name=``%s''\n", - marker[i], filename, - myacls[marker[i]].type, myacls[marker[i]].permset, - myacls[marker[i]].tag, myacls[marker[i]].qual, - myacls[marker[i]].name); - assert(0); /* Record this as a failure. */ - } - free(marker); -} - -static void -compare_entry_acls(struct archive_entry *ae, struct myacl_t *myacls, const char *filename, int start, int end) -{ - int *marker; - int matched; - int i, n; - int type, permset, tag, qual; - const char *name; - - /* Count ACL entries in myacls array and allocate an indirect array. */ - n = end - start; - marker = malloc(sizeof(marker[0]) * (n + 1)); - for (i = 0; i < n; i++) - marker[i] = i + start; - /* Always include the first ACE. */ - if (start > 0) { - marker[n] = 0; - ++n; - } - - /* - * Iterate over acls in entry, try to match each - * one with an item in the myacls array. - */ - assertEqualInt(n, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4)); - while (ARCHIVE_OK == archive_entry_acl_next(ae, - ARCHIVE_ENTRY_ACL_TYPE_NFS4, &type, &permset, &tag, &qual, &name)) { - - /* Search for a matching entry (tag and qualifier) */ - for (i = 0, matched = 0; i < n && !matched; i++) { - if (tag == myacls[marker[i]].tag - && qual == myacls[marker[i]].qual - && permset == myacls[marker[i]].permset - && type == myacls[marker[i]].type) { - /* We found a match; remove it. */ - marker[i] = marker[n - 1]; - n--; - matched = 1; - } - } - - failure("ACL entry on file that shouldn't be there: " - "type=%d,permset=%x,tag=%d,qual=%d", - type,permset,tag,qual); - assert(matched == 1); - } - - /* Dump entries in the myacls array that weren't in the system acl. */ - for (i = 0; i < n; ++i) { - failure(" ACL entry %d missing from %s: " - "type=%d,permset=%x,tag=%d,qual=%d,name=``%s''\n", - marker[i], filename, - myacls[marker[i]].type, myacls[marker[i]].permset, - myacls[marker[i]].tag, myacls[marker[i]].qual, - myacls[marker[i]].name); - assert(0); /* Record this as a failure. */ - } - free(marker); -} -#endif - -/* - * Verify ACL restore-to-disk. This test is FreeBSD-specific. - */ - -DEFINE_TEST(test_acl_freebsd_nfs4) -{ -#if !defined(__FreeBSD__) - skipping("FreeBSD-specific NFS4 ACL restore test"); -#elif __FreeBSD__ < 8 - skipping("NFS4 ACLs supported only on FreeBSD 8.0 and later"); -#else - char buff[64]; - struct stat st; - struct archive *a; - struct archive_entry *ae; - int i, n; - acl_t acl; - - /* - * First, do a quick manual set/read of ACL data to - * verify that the local filesystem does support ACLs. - * If it doesn't, we'll simply skip the remaining tests. - */ - acl = acl_from_text("owner@:rwxp::allow,group@:rwp:f:allow"); - assert((void *)acl != NULL); - /* Create a test dir and try to set an ACL on it. */ - if (!assertMakeDir("pretest", 0755)) { - acl_free(acl); - return; - } - - n = acl_set_file("pretest", ACL_TYPE_NFS4, acl); - acl_free(acl); - if (n != 0 && errno == EOPNOTSUPP) { - skipping("NFS4 ACL tests require that NFS4 ACLs" - " be enabled on the filesystem"); - return; - } - if (n != 0 && errno == EINVAL) { - skipping("This filesystem does not support NFS4 ACLs"); - return; - } - failure("acl_set_file(): errno = %d (%s)", - errno, strerror(errno)); - assertEqualInt(0, n); - - /* Create a write-to-disk object. */ - assert(NULL != (a = archive_write_disk_new())); - archive_write_disk_set_options(a, - ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_ACL); - - /* Populate an archive entry with some metadata, including ACL info */ - ae = archive_entry_new(); - assert(ae != NULL); - archive_entry_set_pathname(ae, "testall"); - archive_entry_set_filetype(ae, AE_IFREG); - archive_entry_set_perm(ae, 0654); - archive_entry_set_mtime(ae, 123456, 7890); - archive_entry_set_size(ae, 0); - set_acls(ae, acls_reg, 0, (int)(sizeof(acls_reg)/sizeof(acls_reg[0]))); - - /* Write the entry to disk, including ACLs. */ - assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); - - /* Likewise for a dir. */ - archive_entry_set_pathname(ae, "dirall"); - archive_entry_set_filetype(ae, AE_IFDIR); - archive_entry_set_perm(ae, 0654); - archive_entry_set_mtime(ae, 123456, 7890); - set_acls(ae, acls_dir, 0, (int)(sizeof(acls_dir)/sizeof(acls_dir[0]))); - assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); - - for (i = 0; i < (int)(sizeof(acls_dir)/sizeof(acls_dir[0])); ++i) { - sprintf(buff, "dir%d", i); - archive_entry_set_pathname(ae, buff); - archive_entry_set_filetype(ae, AE_IFDIR); - archive_entry_set_perm(ae, 0654); - archive_entry_set_mtime(ae, 123456 + i, 7891 + i); - set_acls(ae, acls_dir, i, i + 1); - assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); - } - - archive_entry_free(ae); - - /* Close the archive. */ - assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a)); - assertEqualInt(ARCHIVE_OK, archive_write_free(a)); - - /* Verify the data on disk. */ - assertEqualInt(0, stat("testall", &st)); - assertEqualInt(st.st_mtime, 123456); - acl = acl_get_file("testall", ACL_TYPE_NFS4); - assert(acl != (acl_t)NULL); - compare_acls(acl, acls_reg, "testall", 0, (int)(sizeof(acls_reg)/sizeof(acls_reg[0]))); - acl_free(acl); - - /* Verify single-permission dirs on disk. */ - for (i = 0; i < (int)(sizeof(acls_dir)/sizeof(acls_dir[0])); ++i) { - sprintf(buff, "dir%d", i); - assertEqualInt(0, stat(buff, &st)); - assertEqualInt(st.st_mtime, 123456 + i); - acl = acl_get_file(buff, ACL_TYPE_NFS4); - assert(acl != (acl_t)NULL); - compare_acls(acl, acls_dir, buff, i, i + 1); - acl_free(acl); - } - - /* Verify "dirall" on disk. */ - assertEqualInt(0, stat("dirall", &st)); - assertEqualInt(st.st_mtime, 123456); - acl = acl_get_file("dirall", ACL_TYPE_NFS4); - assert(acl != (acl_t)NULL); - compare_acls(acl, acls_dir, "dirall", 0, (int)(sizeof(acls_dir)/sizeof(acls_dir[0]))); - acl_free(acl); - - /* Read and compare ACL via archive_read_disk */ - a = archive_read_disk_new(); - assert(a != NULL); - ae = archive_entry_new(); - assert(ae != NULL); - archive_entry_set_pathname(ae, "testall"); - assertEqualInt(ARCHIVE_OK, - archive_read_disk_entry_from_file(a, ae, -1, NULL)); - compare_entry_acls(ae, acls_reg, "testall", 0, (int)(sizeof(acls_reg)/sizeof(acls_reg[0]))); - archive_entry_free(ae); - assertEqualInt(ARCHIVE_OK, archive_read_free(a)); - - /* Read and compare ACL via archive_read_disk */ - a = archive_read_disk_new(); - assert(a != NULL); - ae = archive_entry_new(); - assert(ae != NULL); - archive_entry_set_pathname(ae, "dirall"); - assertEqualInt(ARCHIVE_OK, - archive_read_disk_entry_from_file(a, ae, -1, NULL)); - compare_entry_acls(ae, acls_dir, "dirall", 0, (int)(sizeof(acls_dir)/sizeof(acls_dir[0]))); - archive_entry_free(ae); - assertEqualInt(ARCHIVE_OK, archive_read_free(a)); -#endif -} diff --git a/contrib/libarchive/libarchive/test/test_acl_freebsd_posix1e.c b/contrib/libarchive/libarchive/test/test_acl_freebsd_posix1e.c deleted file mode 100644 index 2eb0a00..0000000 --- a/contrib/libarchive/libarchive/test/test_acl_freebsd_posix1e.c +++ /dev/null @@ -1,418 +0,0 @@ -/*- - * Copyright (c) 2003-2008 Tim Kientzle - * 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(S) ``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(S) 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. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_acl_freebsd.c 189427 2009-03-06 04:21:23Z kientzle $"); - -#if defined(__FreeBSD__) && __FreeBSD__ > 4 -#include - -struct myacl_t { - int type; /* Type of ACL: "access" or "default" */ - int permset; /* Permissions for this class of users. */ - int tag; /* Owner, User, Owning group, group, other, etc. */ - int qual; /* GID or UID of user/group, depending on tag. */ - const char *name; /* Name of user/group, depending on tag. */ -}; - -static struct myacl_t acls2[] = { - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0, - ARCHIVE_ENTRY_ACL_USER, 78, "user78" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0007, - ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ | ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_MASK, -1, "" }, - { 0, 0, 0, 0, NULL } -}; - -static void -set_acls(struct archive_entry *ae, struct myacl_t *acls) -{ - int i; - - archive_entry_acl_clear(ae); - for (i = 0; acls[i].name != NULL; i++) { - archive_entry_acl_add_entry(ae, - acls[i].type, acls[i].permset, acls[i].tag, acls[i].qual, - acls[i].name); - } -} - -static int -acl_entry_get_perm(acl_entry_t aclent) { - int permset = 0; - acl_permset_t opaque_ps; - - /* translate the silly opaque permset to a bitmap */ - acl_get_permset(aclent, &opaque_ps); - if (acl_get_perm_np(opaque_ps, ACL_EXECUTE)) - permset |= ARCHIVE_ENTRY_ACL_EXECUTE; - if (acl_get_perm_np(opaque_ps, ACL_WRITE)) - permset |= ARCHIVE_ENTRY_ACL_WRITE; - if (acl_get_perm_np(opaque_ps, ACL_READ)) - permset |= ARCHIVE_ENTRY_ACL_READ; - return permset; -} - -#if 0 -static int -acl_get_specific_entry(acl_t acl, acl_tag_t requested_tag_type, int requested_tag) { - int entry_id = ACL_FIRST_ENTRY; - acl_entry_t acl_entry; - acl_tag_t acl_tag_type; - - while (1 == acl_get_entry(acl, entry_id, &acl_entry)) { - /* After the first time... */ - entry_id = ACL_NEXT_ENTRY; - - /* If this matches, return perm mask */ - acl_get_tag_type(acl_entry, &acl_tag_type); - if (acl_tag_type == requested_tag_type) { - switch (acl_tag_type) { - case ACL_USER_OBJ: - if ((uid_t)requested_tag == *(uid_t *)(acl_get_qualifier(acl_entry))) { - return acl_entry_get_perm(acl_entry); - } - break; - case ACL_GROUP_OBJ: - if ((gid_t)requested_tag == *(gid_t *)(acl_get_qualifier(acl_entry))) { - return acl_entry_get_perm(acl_entry); - } - break; - case ACL_USER: - case ACL_GROUP: - case ACL_OTHER: - return acl_entry_get_perm(acl_entry); - default: - failure("Unexpected ACL tag type"); - assert(0); - } - } - - - } - return -1; -} -#endif - -static int -acl_match(acl_entry_t aclent, struct myacl_t *myacl) -{ - gid_t g, *gp; - uid_t u, *up; - acl_tag_t tag_type; - - if (myacl->permset != acl_entry_get_perm(aclent)) - return (0); - - acl_get_tag_type(aclent, &tag_type); - switch (tag_type) { - case ACL_USER_OBJ: - if (myacl->tag != ARCHIVE_ENTRY_ACL_USER_OBJ) return (0); - break; - case ACL_USER: - if (myacl->tag != ARCHIVE_ENTRY_ACL_USER) - return (0); - up = acl_get_qualifier(aclent); - u = *up; - acl_free(up); - if ((uid_t)myacl->qual != u) - return (0); - break; - case ACL_GROUP_OBJ: - if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP_OBJ) return (0); - break; - case ACL_GROUP: - if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP) - return (0); - gp = acl_get_qualifier(aclent); - g = *gp; - acl_free(gp); - if ((gid_t)myacl->qual != g) - return (0); - break; - case ACL_MASK: - if (myacl->tag != ARCHIVE_ENTRY_ACL_MASK) return (0); - break; - case ACL_OTHER: - if (myacl->tag != ARCHIVE_ENTRY_ACL_OTHER) return (0); - break; - } - return (1); -} - -static void -compare_acls(acl_t acl, struct myacl_t *myacls) -{ - int *marker; - int entry_id = ACL_FIRST_ENTRY; - int matched; - int i, n; - acl_entry_t acl_entry; - - /* Count ACL entries in myacls array and allocate an indirect array. */ - for (n = 0; myacls[n].name != NULL; ++n) - continue; - if (n) { - marker = malloc(sizeof(marker[0]) * n); - if (marker == NULL) - return; - for (i = 0; i < n; i++) - marker[i] = i; - } else - marker = NULL; - - /* - * Iterate over acls in system acl object, try to match each - * one with an item in the myacls array. - */ - while (1 == acl_get_entry(acl, entry_id, &acl_entry)) { - /* After the first time... */ - entry_id = ACL_NEXT_ENTRY; - - /* Search for a matching entry (tag and qualifier) */ - for (i = 0, matched = 0; i < n && !matched; i++) { - if (acl_match(acl_entry, &myacls[marker[i]])) { - /* We found a match; remove it. */ - marker[i] = marker[n - 1]; - n--; - matched = 1; - } - } - - /* TODO: Print out more details in this case. */ - failure("ACL entry on file that shouldn't be there"); - assert(matched == 1); - } - - /* Dump entries in the myacls array that weren't in the system acl. */ - for (i = 0; i < n; ++i) { - failure(" ACL entry missing from file: " - "type=%d,permset=%d,tag=%d,qual=%d,name=``%s''\n", - myacls[marker[i]].type, myacls[marker[i]].permset, - myacls[marker[i]].tag, myacls[marker[i]].qual, - myacls[marker[i]].name); - assert(0); /* Record this as a failure. */ - } - free(marker); -} - -#endif - - -/* - * Verify ACL restore-to-disk. This test is FreeBSD-specific. - */ - -DEFINE_TEST(test_acl_freebsd_posix1e_restore) -{ -#if !defined(__FreeBSD__) - skipping("FreeBSD-specific ACL restore test"); -#elif __FreeBSD__ < 5 - skipping("ACL restore supported only on FreeBSD 5.0 and later"); -#else - struct stat st; - struct archive *a; - struct archive_entry *ae; - int n, fd; - acl_t acl; - - /* - * First, do a quick manual set/read of ACL data to - * verify that the local filesystem does support ACLs. - * If it doesn't, we'll simply skip the remaining tests. - */ - acl = acl_from_text("u::rwx,u:1:rw,g::rwx,g:15:rx,o::rwx,m::rwx"); - assert((void *)acl != NULL); - /* Create a test file and try to set an ACL on it. */ - fd = open("pretest", O_WRONLY | O_CREAT | O_EXCL, 0777); - failure("Could not create test file?!"); - if (!assert(fd >= 0)) { - acl_free(acl); - return; - } - - n = acl_set_fd(fd, acl); - acl_free(acl); - if (n != 0 && errno == EOPNOTSUPP) { - close(fd); - skipping("ACL tests require that ACL support be enabled on the filesystem"); - return; - } - if (n != 0 && errno == EINVAL) { - close(fd); - skipping("This filesystem does not support POSIX.1e ACLs"); - return; - } - failure("acl_set_fd(): errno = %d (%s)", - errno, strerror(errno)); - assertEqualInt(0, n); - close(fd); - - /* Create a write-to-disk object. */ - assert(NULL != (a = archive_write_disk_new())); - archive_write_disk_set_options(a, - ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_ACL); - - /* Populate an archive entry with some metadata, including ACL info */ - ae = archive_entry_new(); - assert(ae != NULL); - archive_entry_set_pathname(ae, "test0"); - archive_entry_set_mtime(ae, 123456, 7890); - archive_entry_set_size(ae, 0); - set_acls(ae, acls2); - assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); - archive_entry_free(ae); - - /* Close the archive. */ - assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a)); - assertEqualInt(ARCHIVE_OK, archive_write_free(a)); - - /* Verify the data on disk. */ - assertEqualInt(0, stat("test0", &st)); - assertEqualInt(st.st_mtime, 123456); - acl = acl_get_file("test0", ACL_TYPE_ACCESS); - assert(acl != (acl_t)NULL); - compare_acls(acl, acls2); - acl_free(acl); -#endif -} - -/* - * Verify ACL reaed-from-disk. This test is FreeBSD-specific. - */ -DEFINE_TEST(test_acl_freebsd_posix1e_read) -{ -#if !defined(__FreeBSD__) - skipping("FreeBSD-specific ACL read test"); -#elif __FreeBSD__ < 5 - skipping("ACL read supported only on FreeBSD 5.0 and later"); -#else - struct archive *a; - struct archive_entry *ae; - int n, fd; - const char *acl1_text, *acl2_text; - acl_t acl1, acl2; - - /* - * Manually construct a directory and two files with - * different ACLs. This also serves to verify that ACLs - * are supported on the local filesystem. - */ - - /* Create a test file f1 with acl1 */ - acl1_text = "user::rwx,group::rwx,other::rwx,user:1:rw-,group:15:r-x,mask::rwx"; - acl1 = acl_from_text(acl1_text); - assert((void *)acl1 != NULL); - fd = open("f1", O_WRONLY | O_CREAT | O_EXCL, 0777); - failure("Could not create test file?!"); - if (!assert(fd >= 0)) { - acl_free(acl1); - return; - } - n = acl_set_fd(fd, acl1); - acl_free(acl1); - if (n != 0 && errno == EOPNOTSUPP) { - close(fd); - skipping("ACL tests require that ACL support be enabled on the filesystem"); - return; - } - if (n != 0 && errno == EINVAL) { - close(fd); - skipping("This filesystem does not support POSIX.1e ACLs"); - return; - } - failure("acl_set_fd(): errno = %d (%s)", - errno, strerror(errno)); - assertEqualInt(0, n); - close(fd); - - assertMakeDir("d", 0700); - - /* - * Create file d/f1 with acl2 - * - * This differs from acl1 in the u:1: and g:15: permissions. - * - * This file deliberately has the same name but a different ACL. - * Github Issue #777 explains how libarchive's directory traversal - * did not always correctly enter directories before attempting - * to read ACLs, resulting in reading the ACL from a like-named - * file in the wrong directory. - */ - acl2_text = "user::rwx,group::rwx,other::---,user:1:r--,group:15:r--,mask::rwx"; - acl2 = acl_from_text(acl2_text); - assert((void *)acl2 != NULL); - fd = open("d/f1", O_WRONLY | O_CREAT | O_EXCL, 0777); - failure("Could not create test file?!"); - if (!assert(fd >= 0)) { - acl_free(acl2); - return; - } - n = acl_set_fd(fd, acl2); - acl_free(acl2); - if (n != 0 && errno == EOPNOTSUPP) { - close(fd); - skipping("ACL tests require that ACL support be enabled on the filesystem"); - return; - } - if (n != 0 && errno == EINVAL) { - close(fd); - skipping("This filesystem does not support POSIX.1e ACLs"); - return; - } - failure("acl_set_fd(): errno = %d (%s)", - errno, strerror(errno)); - assertEqualInt(0, n); - close(fd); - - /* Create a read-from-disk object. */ - assert(NULL != (a = archive_read_disk_new())); - assertEqualIntA(a, ARCHIVE_OK, archive_read_disk_open(a, ".")); - assert(NULL != (ae = archive_entry_new())); - - /* Walk the dir until we see both of the files */ - while (ARCHIVE_OK == archive_read_next_header2(a, ae)) { - archive_read_disk_descend(a); - if (strcmp(archive_entry_pathname(ae), "./f1") == 0) { - assertEqualString(archive_entry_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS), acl1_text); - - } else if (strcmp(archive_entry_pathname(ae), "./d/f1") == 0) { - assertEqualString(archive_entry_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS), acl2_text); - } - } - - archive_free(a); -#endif -} diff --git a/contrib/libarchive/libarchive/test/test_acl_nfs4.c b/contrib/libarchive/libarchive/test/test_acl_nfs4.c index c8f5937..f4e66f5 100644 --- a/contrib/libarchive/libarchive/test/test_acl_nfs4.c +++ b/contrib/libarchive/libarchive/test/test_acl_nfs4.c @@ -33,15 +33,7 @@ __FBSDID("$FreeBSD$"); * filesystems support ACLs or not. */ -struct acl_t { - int type; /* Type of entry: "allow" or "deny" */ - int permset; /* Permissions for this class of users. */ - int tag; /* Owner, User, Owning group, group, everyone, etc. */ - int qual; /* GID or UID of user/group, depending on tag. */ - const char *name; /* Name of user/group, depending on tag. */ -}; - -static struct acl_t acls1[] = { +static struct archive_test_acl_t acls1[] = { { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE, ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, { ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_READ_DATA, @@ -52,7 +44,7 @@ static struct acl_t acls1[] = { ARCHIVE_ENTRY_ACL_EVERYONE, -1, "" }, }; -static struct acl_t acls2[] = { +static struct archive_test_acl_t acls2[] = { /* An entry for each type. */ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, 0, ARCHIVE_ENTRY_ACL_USER, 108, "user108" }, @@ -136,7 +128,7 @@ static struct acl_t acls2[] = { * Entries that should be rejected when we attempt to set them * on an ACL that already has NFS4 entries. */ -static struct acl_t acls_bad[] = { +static struct archive_test_acl_t acls_bad[] = { /* POSIX.1e ACL types */ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, ARCHIVE_ENTRY_ACL_USER, 78, "" }, @@ -156,95 +148,6 @@ static struct acl_t acls_bad[] = { ARCHIVE_ENTRY_ACL_EVERYONE, -1, "" }, }; -static void -set_acls(struct archive_entry *ae, struct acl_t *acls, int n) -{ - int i; - - archive_entry_acl_clear(ae); - for (i = 0; i < n; i++) { - failure("type=%d, permset=%d, tag=%d, qual=%d name=%s", - acls[i].type, acls[i].permset, acls[i].tag, - acls[i].qual, acls[i].name); - assertEqualInt(ARCHIVE_OK, - archive_entry_acl_add_entry(ae, - acls[i].type, acls[i].permset, acls[i].tag, - acls[i].qual, acls[i].name)); - } -} - -static int -acl_match(struct acl_t *acl, int type, int permset, int tag, int qual, - const char *name) -{ - if (acl == NULL) - return (0); - if (type != acl->type) - return (0); - if (permset != acl->permset) - return (0); - if (tag != acl->tag) - return (0); - if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) - return (1); - if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) - return (1); - if (tag == ARCHIVE_ENTRY_ACL_EVERYONE) - return (1); - if (qual != acl->qual) - return (0); - if (name == NULL) { - if (acl->name == NULL || acl->name[0] == '\0') - return (1); - return (0); - } - if (acl->name == NULL) { - if (name[0] == '\0') - return (1); - return (0); - } - return (0 == strcmp(name, acl->name)); -} - -static void -compare_acls(struct archive_entry *ae, struct acl_t *acls, int n) -{ - int *marker = malloc(sizeof(marker[0]) * n); - int i; - int r; - int type, permset, tag, qual; - int matched; - const char *name; - - for (i = 0; i < n; i++) - marker[i] = i; - - while (0 == (r = archive_entry_acl_next(ae, - ARCHIVE_ENTRY_ACL_TYPE_NFS4, - &type, &permset, &tag, &qual, &name))) { - for (i = 0, matched = 0; i < n && !matched; i++) { - if (acl_match(&acls[marker[i]], type, permset, - tag, qual, name)) { - /* We found a match; remove it. */ - marker[i] = marker[n - 1]; - n--; - matched = 1; - } - } - failure("Could not find match for ACL " - "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", - type, permset, tag, qual, name); - assertEqualInt(1, matched); - } - assertEqualInt(ARCHIVE_EOF, r); - failure("Could not find match for ACL " - "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", - acls[marker[0]].type, acls[marker[0]].permset, - acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name); - assertEqualInt(0, n); /* Number of ACLs not matched should == 0 */ - free(marker); -} - DEFINE_TEST(test_acl_nfs4) { struct archive_entry *ae; @@ -256,22 +159,31 @@ DEFINE_TEST(test_acl_nfs4) archive_entry_set_mode(ae, S_IFREG | 0777); /* Store and read back some basic ACL entries. */ - set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); + archive_test_set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); + + /* Check that entry contains only NFSv4 types */ + assert((archive_entry_acl_types(ae) & + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) == 0); + assert((archive_entry_acl_types(ae) & + ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0); + assertEqualInt(4, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4)); - compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); + archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), + ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0); /* A more extensive set of ACLs. */ - set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); + archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); assertEqualInt(32, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4)); - compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); + archive_test_compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), + ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0); /* * Check that clearing ACLs gets rid of them all by repeating * the first test. */ - set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); + archive_test_set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); failure("Basic ACLs shouldn't be stored as extended ACLs"); assertEqualInt(4, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4)); @@ -280,9 +192,9 @@ DEFINE_TEST(test_acl_nfs4) * Different types of malformed ACL entries that should * fail when added to existing NFS4 ACLs. */ - set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); + archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); for (i = 0; i < (int)(sizeof(acls_bad)/sizeof(acls_bad[0])); ++i) { - struct acl_t *p = &acls_bad[i]; + struct archive_test_acl_t *p = &acls_bad[i]; failure("Malformed ACL test #%d", i); assertEqualInt(ARCHIVE_FAILED, archive_entry_acl_add_entry(ae, diff --git a/contrib/libarchive/libarchive/test/test_acl_pax.c b/contrib/libarchive/libarchive/test/test_acl_pax.c index 5fcf61b..8dfa0e0 100644 --- a/contrib/libarchive/libarchive/test/test_acl_pax.c +++ b/contrib/libarchive/libarchive/test/test_acl_pax.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2016 Martin Matuska * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,7 +28,7 @@ __FBSDID("$FreeBSD$"); /* * Exercise the system-independent portion of the ACL support. - * Check that pax archive can save and restore ACL data. + * Check that pax archive can save and restore POSIX.1e ACL data. * * This should work on all systems, regardless of whether local * filesystems support ACLs or not. @@ -35,15 +36,7 @@ __FBSDID("$FreeBSD$"); static unsigned char buff[16384]; -struct acl_t { - int type; /* Type of ACL: "access" or "default" */ - int permset; /* Permissions for this class of users. */ - int tag; /* Owner, User, Owning group, group, other, etc. */ - int qual; /* GID or UID of user/group, depending on tag. */ - const char *name; /* Name of user/group, depending on tag. */ -}; - -static struct acl_t acls0[] = { +static struct archive_test_acl_t acls0[] = { { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" }, { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, @@ -52,7 +45,7 @@ static struct acl_t acls0[] = { ARCHIVE_ENTRY_ACL_OTHER, 0, "" }, }; -static struct acl_t acls1[] = { +static struct archive_test_acl_t acls1[] = { { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, @@ -63,7 +56,7 @@ static struct acl_t acls1[] = { ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, }; -static struct acl_t acls2[] = { +static struct archive_test_acl_t acls2[] = { { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ, ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, @@ -78,101 +71,149 @@ static struct acl_t acls2[] = { ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, }; -static void -set_acls(struct archive_entry *ae, struct acl_t *acls, int n) -{ - int i; - - archive_entry_acl_clear(ae); - for (i = 0; i < n; i++) { - archive_entry_acl_add_entry(ae, - acls[i].type, acls[i].permset, acls[i].tag, acls[i].qual, - acls[i].name); - } -} +static struct archive_test_acl_t acls3[] = { + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_WRITE_ACL | + ARCHIVE_ENTRY_ACL_WRITE_OWNER | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_EVERYONE, 0, "" }, +}; -static int -acl_match(struct acl_t *acl, int type, int permset, int tag, int qual, const char *name) -{ - if (type != acl->type) - return (0); - if (permset != acl->permset) - return (0); - if (tag != acl->tag) - return (0); - if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) - return (1); - if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) - return (1); - if (tag == ARCHIVE_ENTRY_ACL_OTHER) - return (1); - if (qual != acl->qual) - return (0); - if (name == NULL) - return (acl->name == NULL || acl->name[0] == '\0'); - if (acl->name == NULL) - return (name == NULL || name[0] == '\0'); - return (0 == strcmp(name, acl->name)); -} +static struct archive_test_acl_t acls4[] = { + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_WRITE_ACL | + ARCHIVE_ENTRY_ACL_WRITE_OWNER | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE | + ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, + ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, + { ARCHIVE_ENTRY_ACL_TYPE_DENY, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_EXECUTE, + ARCHIVE_ENTRY_ACL_USER, 78, "user78" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_DENY, + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_WRITE_ACL | + ARCHIVE_ENTRY_ACL_WRITE_OWNER, + ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_EVERYONE, 0, "" }, +}; -static void -compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode) -{ - int *marker = malloc(sizeof(marker[0]) * n); - int i; - int r; - int type, permset, tag, qual; - int matched; - const char *name; - - for (i = 0; i < n; i++) - marker[i] = i; - - while (0 == (r = archive_entry_acl_next(ae, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name))) { - for (i = 0, matched = 0; i < n && !matched; i++) { - if (acl_match(&acls[marker[i]], type, permset, - tag, qual, name)) { - /* We found a match; remove it. */ - marker[i] = marker[n - 1]; - n--; - matched = 1; - } - } - if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) { - if (!matched) printf("No match for user_obj perm\n"); - failure("USER_OBJ permset (%02o) != user mode (%02o)", - permset, 07 & (mode >> 6)); - assert((permset << 6) == (mode & 0700)); - } else if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) { - if (!matched) printf("No match for group_obj perm\n"); - failure("GROUP_OBJ permset %02o != group mode %02o", - permset, 07 & (mode >> 3)); - assert((permset << 3) == (mode & 0070)); - } else if (tag == ARCHIVE_ENTRY_ACL_OTHER) { - if (!matched) printf("No match for other perm\n"); - failure("OTHER permset (%02o) != other mode (%02o)", - permset, mode & 07); - assert((permset << 0) == (mode & 0007)); - } else { - failure("Could not find match for ACL " - "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", - type, permset, tag, qual, name); - assert(matched == 1); - } - } - assertEqualInt(ARCHIVE_EOF, r); - assert((mode_t)(mode & 0777) == (archive_entry_mode(ae) & 0777)); - failure("Could not find match for ACL " - "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", - acls[marker[0]].type, acls[marker[0]].permset, - acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name); - assert(n == 0); /* Number of ACLs not matched should == 0 */ - free(marker); -} +static struct archive_test_acl_t acls5[] = { + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_WRITE_ACL | + ARCHIVE_ENTRY_ACL_WRITE_OWNER | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_WRITE_OWNER | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, + { ARCHIVE_ENTRY_ACL_TYPE_AUDIT, + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, + ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALARM, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, + ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_EVERYONE, 0, "" }, +}; -DEFINE_TEST(test_acl_pax) +DEFINE_TEST(test_acl_pax_posix1e) { struct archive *a; struct archive_entry *ae; @@ -197,23 +238,23 @@ DEFINE_TEST(test_acl_pax) archive_entry_set_mode(ae, S_IFREG | 0777); /* Basic owner/owning group should just update mode bits. */ - set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); + archive_test_set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); assertA(0 == archive_write_header(a, ae)); /* With any extended ACL entry, we should read back a full set. */ - set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); + archive_test_set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); assertA(0 == archive_write_header(a, ae)); /* A more extensive set of ACLs. */ - set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); + archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); assertA(0 == archive_write_header(a, ae)); /* * Check that clearing ACLs gets rid of them all by repeating * the first test. */ - set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); + archive_test_set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); assertA(0 == archive_write_header(a, ae)); archive_entry_free(ae); @@ -227,13 +268,13 @@ DEFINE_TEST(test_acl_pax) fclose(f); /* Write out the reference data to a file for manual inspection. */ - extract_reference_file("test_acl_pax.tar"); - reference = slurpfile(&reference_size, "test_acl_pax.tar"); + extract_reference_file("test_acl_pax_posix1e.tar"); + reference = slurpfile(&reference_size, "test_acl_pax_posix1e.tar"); /* Assert that the generated data matches the built-in reference data.*/ - failure("Generated pax archive does not match reference; compare 'testout' to 'test_acl_pax.tar' reference file."); + failure("Generated pax archive does not match reference; compare 'testout' to 'test_acl_pax_posix1e.tar' reference file."); assertEqualMem(buff, reference, reference_size); - failure("Generated pax archive does not match reference; compare 'testout' to 'test_acl_pax.tar' reference file."); + failure("Generated pax archive does not match reference; compare 'testout' to 'test_acl_pax_posix1e.tar' reference file."); assertEqualInt((int)used, reference_size); free(reference); @@ -255,15 +296,18 @@ DEFINE_TEST(test_acl_pax) assertA(0 == archive_read_next_header(a, &ae)); failure("One extended ACL should flag all ACLs to be returned."); assert(4 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), 0142); + archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), + ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0142); failure("Basic ACLs should set mode to 0142, not %04o", archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0142); /* Third item has pretty extensive ACLs */ assertA(0 == archive_read_next_header(a, &ae)); - assertEqualInt(6, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), 0543); + assertEqualInt(6, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); + archive_test_compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), + ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0543); failure("Basic ACLs should set mode to 0543, not %04o", archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0543); @@ -280,3 +324,93 @@ DEFINE_TEST(test_acl_pax) assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } + +DEFINE_TEST(test_acl_pax_nfs4) +{ + struct archive *a; + struct archive_entry *ae; + size_t used; + FILE *f; + void *reference; + size_t reference_size; + + /* Write an archive to memory. */ + assert(NULL != (a = archive_write_new())); + assertA(0 == archive_write_set_format_pax(a)); + assertA(0 == archive_write_add_filter_none(a)); + assertA(0 == archive_write_set_bytes_per_block(a, 1)); + assertA(0 == archive_write_set_bytes_in_last_block(a, 1)); + assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); + + /* Write a series of files to the archive with different ACL info. */ + + /* Create a simple archive_entry. */ + assert((ae = archive_entry_new()) != NULL); + archive_entry_set_pathname(ae, "file"); + archive_entry_set_mode(ae, S_IFREG | 0777); + + /* NFS4 ACLs mirroring 0754 file mode */ + archive_test_set_acls(ae, acls3, sizeof(acls3)/sizeof(acls3[0])); + assertA(0 == archive_write_header(a, ae)); + + /* A more extensive set of NFS4 ACLs. */ + archive_test_set_acls(ae, acls4, sizeof(acls4)/sizeof(acls4[0])); + assertA(0 == archive_write_header(a, ae)); + + /* Set with special (audit, alarm) NFS4 ACLs. */ + archive_test_set_acls(ae, acls5, sizeof(acls5)/sizeof(acls5[0])); + assertA(0 == archive_write_header(a, ae)); + + archive_entry_free(ae); + + /* Close out the archive. */ + assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a)); + assertEqualInt(ARCHIVE_OK, archive_write_free(a)); + + /* Write out the data we generated to a file for manual inspection. */ + assert(NULL != (f = fopen("testout", "wb"))); + assertEqualInt(used, (size_t)fwrite(buff, 1, (unsigned int)used, f)); + fclose(f); + + /* Write out the reference data to a file for manual inspection. */ + extract_reference_file("test_acl_pax_nfs4.tar"); + reference = slurpfile(&reference_size, "test_acl_pax_nfs4.tar"); + + /* Assert that the generated data matches the built-in reference data.*/ + failure("Generated pax archive does not match reference; compare 'testout' to 'test_acl_pax_nfs4.tar' reference file."); + assertEqualMem(buff, reference, reference_size); + failure("Generated pax archive does not match reference; compare 'testout' to 'test_acl_pax_nfs4.tar' reference file."); + assertEqualInt((int)used, reference_size); + free(reference); + + /* Read back each entry and check that the ACL data is right. */ + assert(NULL != (a = archive_read_new())); + assertA(0 == archive_read_support_format_all(a)); + assertA(0 == archive_read_support_filter_all(a)); + assertA(0 == archive_read_open_memory(a, buff, used)); + + /* First item has NFS4 ACLs mirroring file mode */ + assertA(0 == archive_read_next_header(a, &ae)); + assertEqualInt(3, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_ALLOW)); + archive_test_compare_acls(ae, acls3, sizeof(acls3)/sizeof(acls3[0]), + ARCHIVE_ENTRY_ACL_TYPE_ALLOW, 0); + + /* Second item has has more fine-grained NFS4 ACLs */ + assertA(0 == archive_read_next_header(a, &ae)); + assertEqualInt(6, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_NFS4)); + archive_test_compare_acls(ae, acls4, sizeof(acls4)/sizeof(acls4[0]), + ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0); + + /* Third item has has audit and alarm NFS4 ACLs */ + assertA(0 == archive_read_next_header(a, &ae)); + assertEqualInt(6, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_NFS4)); + archive_test_compare_acls(ae, acls5, sizeof(acls5)/sizeof(acls5[0]), + ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0); + + /* Close the archive. */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} diff --git a/contrib/libarchive/libarchive/test/test_acl_pax.tar.uu b/contrib/libarchive/libarchive/test/test_acl_pax.tar.uu deleted file mode 100644 index 58d7b62..0000000 --- a/contrib/libarchive/libarchive/test/test_acl_pax.tar.uu +++ /dev/null @@ -1,117 +0,0 @@ -begin 644 test_acl_pax.tar -M9FEL90`````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````#`P,#$T,B``,#`P,#`P(``P,#`P,#`@`#`P,#`P,#`P,#`P -M(#`P,#`P,#`P,#`P(#`Q,#`P-@`@,``````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````!U"QG``````````````````````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````!U'`M+6%!4E=C0V]S.BTM+2TM+2TZ86QL;W``````````````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````````````!U``````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````````````````````!U +M'`M+6%!4E=C0V]S.BTM+2TM+2TZ86QL;W6]N94`Z"QG +#if HAVE_DARWIN_ACL +#include +#endif +#endif + +#if HAVE_NFS4_ACL +struct myacl_t { + int type; + int permset; + int tag; + int qual; /* GID or UID of user/group, depending on tag. */ + const char *name; /* Name of user/group, depending on tag. */ +}; + +static struct myacl_t acls_reg[] = { +#if !HAVE_DARWIN_ACL + /* For this test, we need the file owner to be able to read and write the ACL. */ + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_READ_ACL | ARCHIVE_ENTRY_ACL_WRITE_ACL | ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, + ARCHIVE_ENTRY_ACL_USER_OBJ, -1, ""}, +#endif + /* An entry for each type. */ + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE, + ARCHIVE_ENTRY_ACL_USER, 108, "user108" }, + { ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_EXECUTE, + ARCHIVE_ENTRY_ACL_USER, 109, "user109" }, + + /* An entry for each permission. */ + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE, + ARCHIVE_ENTRY_ACL_USER, 112, "user112" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_DATA, + ARCHIVE_ENTRY_ACL_USER, 113, "user113" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_DATA, + ARCHIVE_ENTRY_ACL_USER, 115, "user115" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_APPEND_DATA, + ARCHIVE_ENTRY_ACL_USER, 117, "user117" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, + ARCHIVE_ENTRY_ACL_USER, 119, "user119" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, + ARCHIVE_ENTRY_ACL_USER, 120, "user120" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, + ARCHIVE_ENTRY_ACL_USER, 122, "user122" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, + ARCHIVE_ENTRY_ACL_USER, 123, "user123" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_DELETE, + ARCHIVE_ENTRY_ACL_USER, 124, "user124" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_ACL, + ARCHIVE_ENTRY_ACL_USER, 125, "user125" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_ACL, + ARCHIVE_ENTRY_ACL_USER, 126, "user126" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_OWNER, + ARCHIVE_ENTRY_ACL_USER, 127, "user127" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_USER, 128, "user128" }, + + /* One entry for each qualifier. */ + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE, + ARCHIVE_ENTRY_ACL_USER, 135, "user135" }, +// { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE, +// ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE, + ARCHIVE_ENTRY_ACL_GROUP, 136, "group136" }, +#if !HAVE_DARWIN_ACL + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE, + ARCHIVE_ENTRY_ACL_EVERYONE, -1, "" } +#else /* MacOS - mode 0654 */ + { ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_EXECUTE, + ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_WRITE_ACL | + ARCHIVE_ENTRY_ACL_WRITE_OWNER | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_EVERYONE, -1, "" } +#endif +}; + +static const int acls_reg_cnt = (int)(sizeof(acls_reg)/sizeof(acls_reg[0])); + +static struct myacl_t acls_dir[] = { + /* For this test, we need to be able to read and write the ACL. */ +#if !HAVE_DARWIN_ACL + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_READ_ACL, + ARCHIVE_ENTRY_ACL_USER_OBJ, -1, ""}, +#endif + + /* An entry for each type. */ + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, + ARCHIVE_ENTRY_ACL_USER, 101, "user101" }, + { ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, + ARCHIVE_ENTRY_ACL_USER, 102, "user102" }, + + /* An entry for each permission. */ + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, + ARCHIVE_ENTRY_ACL_USER, 201, "user201" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_ADD_FILE, + ARCHIVE_ENTRY_ACL_USER, 202, "user202" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, + ARCHIVE_ENTRY_ACL_USER, 203, "user203" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, + ARCHIVE_ENTRY_ACL_USER, 204, "user204" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, + ARCHIVE_ENTRY_ACL_USER, 205, "user205" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_DELETE_CHILD, + ARCHIVE_ENTRY_ACL_USER, 206, "user206" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, + ARCHIVE_ENTRY_ACL_USER, 207, "user207" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, + ARCHIVE_ENTRY_ACL_USER, 208, "user208" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_DELETE, + ARCHIVE_ENTRY_ACL_USER, 209, "user209" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_ACL, + ARCHIVE_ENTRY_ACL_USER, 210, "user210" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_ACL, + ARCHIVE_ENTRY_ACL_USER, 211, "user211" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_WRITE_OWNER, + ARCHIVE_ENTRY_ACL_USER, 212, "user212" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_USER, 213, "user213" }, + + /* One entry with each inheritance value. */ + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, + ARCHIVE_ENTRY_ACL_USER, 301, "user301" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, + ARCHIVE_ENTRY_ACL_USER, 302, "user302" }, +#if 0 + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, + ARCHIVE_ENTRY_ACL_USER, 303, "user303" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, + ARCHIVE_ENTRY_ACL_USER, 304, "user304" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, + ARCHIVE_ENTRY_ACL_USER, 305, "user305" }, +#endif + +#if 0 + /* FreeBSD does not support audit entries. */ + { ARCHIVE_ENTRY_ACL_TYPE_AUDIT, + ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, + ARCHIVE_ENTRY_ACL_USER, 401, "user401" }, + { ARCHIVE_ENTRY_ACL_TYPE_AUDIT, + ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, + ARCHIVE_ENTRY_ACL_USER, 402, "user402" }, +#endif + + /* One entry for each qualifier. */ + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, + ARCHIVE_ENTRY_ACL_USER, 501, "user501" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, + ARCHIVE_ENTRY_ACL_GROUP, 502, "group502" }, +#if !HAVE_DARWIN_ACL + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, + ARCHIVE_ENTRY_ACL_EVERYONE, -1, "" } +#else /* MacOS - mode 0654 */ + { ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_EXECUTE, + ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_WRITE_ACL | + ARCHIVE_ENTRY_ACL_WRITE_OWNER | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_EVERYONE, -1, "" } +#endif +}; + +static const int acls_dir_cnt = (int)(sizeof(acls_dir)/sizeof(acls_dir[0])); + +static void +set_acls(struct archive_entry *ae, struct myacl_t *acls, int start, int end) +{ + int i; + + archive_entry_acl_clear(ae); + if (start > 0) { + assertEqualInt(ARCHIVE_OK, + archive_entry_acl_add_entry(ae, + acls[0].type, acls[0].permset, acls[0].tag, + acls[0].qual, acls[0].name)); + } + for (i = start; i < end; i++) { + assertEqualInt(ARCHIVE_OK, + archive_entry_acl_add_entry(ae, + acls[i].type, acls[i].permset, acls[i].tag, + acls[i].qual, acls[i].name)); + } +} + +static int +#ifdef HAVE_SUN_ACL +acl_permset_to_bitmap(uint32_t a_access_mask) +#else +acl_permset_to_bitmap(acl_permset_t opaque_ps) +#endif +{ + static struct { int machine; int portable; } perms[] = { +#ifdef HAVE_SUN_ACL /* Solaris NFSv4 ACL permissions */ + {ACE_EXECUTE, ARCHIVE_ENTRY_ACL_EXECUTE}, + {ACE_READ_DATA, ARCHIVE_ENTRY_ACL_READ_DATA}, + {ACE_LIST_DIRECTORY, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY}, + {ACE_WRITE_DATA, ARCHIVE_ENTRY_ACL_WRITE_DATA}, + {ACE_ADD_FILE, ARCHIVE_ENTRY_ACL_ADD_FILE}, + {ACE_APPEND_DATA, ARCHIVE_ENTRY_ACL_APPEND_DATA}, + {ACE_ADD_SUBDIRECTORY, ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY}, + {ACE_READ_NAMED_ATTRS, ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS}, + {ACE_WRITE_NAMED_ATTRS, ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS}, + {ACE_DELETE_CHILD, ARCHIVE_ENTRY_ACL_DELETE_CHILD}, + {ACE_READ_ATTRIBUTES, ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES}, + {ACE_WRITE_ATTRIBUTES, ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES}, + {ACE_DELETE, ARCHIVE_ENTRY_ACL_DELETE}, + {ACE_READ_ACL, ARCHIVE_ENTRY_ACL_READ_ACL}, + {ACE_WRITE_ACL, ARCHIVE_ENTRY_ACL_WRITE_ACL}, + {ACE_WRITE_OWNER, ARCHIVE_ENTRY_ACL_WRITE_OWNER}, + {ACE_SYNCHRONIZE, ARCHIVE_ENTRY_ACL_SYNCHRONIZE} +#elif HAVE_DARWIN_ACL /* MacOS NFSv4 ACL permissions */ + {ACL_READ_DATA, ARCHIVE_ENTRY_ACL_READ_DATA}, + {ACL_LIST_DIRECTORY, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY}, + {ACL_WRITE_DATA, ARCHIVE_ENTRY_ACL_WRITE_DATA}, + {ACL_ADD_FILE, ARCHIVE_ENTRY_ACL_ADD_FILE}, + {ACL_EXECUTE, ARCHIVE_ENTRY_ACL_EXECUTE}, + {ACL_DELETE, ARCHIVE_ENTRY_ACL_DELETE}, + {ACL_APPEND_DATA, ARCHIVE_ENTRY_ACL_APPEND_DATA}, + {ACL_ADD_SUBDIRECTORY, ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY}, + {ACL_DELETE_CHILD, ARCHIVE_ENTRY_ACL_DELETE_CHILD}, + {ACL_READ_ATTRIBUTES, ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES}, + {ACL_WRITE_ATTRIBUTES, ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES}, + {ACL_READ_EXTATTRIBUTES, ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS}, + {ACL_WRITE_EXTATTRIBUTES, ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS}, + {ACL_READ_SECURITY, ARCHIVE_ENTRY_ACL_READ_ACL}, + {ACL_WRITE_SECURITY, ARCHIVE_ENTRY_ACL_WRITE_ACL}, + {ACL_CHANGE_OWNER, ARCHIVE_ENTRY_ACL_WRITE_OWNER}, + {ACL_SYNCHRONIZE, ARCHIVE_ENTRY_ACL_SYNCHRONIZE}, +#else /* FreeBSD NFSv4 ACL permissions */ + {ACL_EXECUTE, ARCHIVE_ENTRY_ACL_EXECUTE}, + {ACL_WRITE, ARCHIVE_ENTRY_ACL_WRITE}, + {ACL_READ, ARCHIVE_ENTRY_ACL_READ}, + {ACL_READ_DATA, ARCHIVE_ENTRY_ACL_READ_DATA}, + {ACL_LIST_DIRECTORY, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY}, + {ACL_WRITE_DATA, ARCHIVE_ENTRY_ACL_WRITE_DATA}, + {ACL_ADD_FILE, ARCHIVE_ENTRY_ACL_ADD_FILE}, + {ACL_APPEND_DATA, ARCHIVE_ENTRY_ACL_APPEND_DATA}, + {ACL_ADD_SUBDIRECTORY, ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY}, + {ACL_READ_NAMED_ATTRS, ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS}, + {ACL_WRITE_NAMED_ATTRS, ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS}, + {ACL_DELETE_CHILD, ARCHIVE_ENTRY_ACL_DELETE_CHILD}, + {ACL_READ_ATTRIBUTES, ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES}, + {ACL_WRITE_ATTRIBUTES, ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES}, + {ACL_DELETE, ARCHIVE_ENTRY_ACL_DELETE}, + {ACL_READ_ACL, ARCHIVE_ENTRY_ACL_READ_ACL}, + {ACL_WRITE_ACL, ARCHIVE_ENTRY_ACL_WRITE_ACL}, + {ACL_WRITE_OWNER, ARCHIVE_ENTRY_ACL_WRITE_OWNER}, + {ACL_SYNCHRONIZE, ARCHIVE_ENTRY_ACL_SYNCHRONIZE} +#endif + }; + int i, permset = 0; + + for (i = 0; i < (int)(sizeof(perms)/sizeof(perms[0])); ++i) +#if HAVE_SUN_ACL + if (a_access_mask & perms[i].machine) +#else + if (acl_get_perm_np(opaque_ps, perms[i].machine)) +#endif + permset |= perms[i].portable; + return permset; +} + +static int +#if HAVE_SUN_ACL +acl_flagset_to_bitmap(uint16_t a_flags) +#else +acl_flagset_to_bitmap(acl_flagset_t opaque_fs) +#endif +{ + static struct { int machine; int portable; } flags[] = { +#if HAVE_SUN_ACL /* Solaris NFSv4 ACL inheritance flags */ + {ACE_FILE_INHERIT_ACE, ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT}, + {ACE_DIRECTORY_INHERIT_ACE, ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT}, + {ACE_NO_PROPAGATE_INHERIT_ACE, ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT}, + {ACE_INHERIT_ONLY_ACE, ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY}, + {ACE_SUCCESSFUL_ACCESS_ACE_FLAG, ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS}, + {ACE_FAILED_ACCESS_ACE_FLAG, ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS}, + {ACE_INHERITED_ACE, ARCHIVE_ENTRY_ACL_ENTRY_INHERITED} +#elif HAVE_DARWIN_ACL /* MacOS NFSv4 ACL inheritance flags */ + {ACL_ENTRY_INHERITED, ARCHIVE_ENTRY_ACL_ENTRY_INHERITED}, + {ACL_ENTRY_FILE_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT}, + {ACL_ENTRY_DIRECTORY_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT}, + {ACL_ENTRY_LIMIT_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT}, + {ACL_ENTRY_ONLY_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY} +#else /* FreeBSD NFSv4 ACL inheritance flags */ + {ACL_ENTRY_FILE_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT}, + {ACL_ENTRY_DIRECTORY_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT}, + {ACL_ENTRY_NO_PROPAGATE_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT}, + {ACL_ENTRY_SUCCESSFUL_ACCESS, ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS}, + {ACL_ENTRY_NO_PROPAGATE_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS}, + {ACL_ENTRY_INHERIT_ONLY, ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY}, +#endif + }; + int i, flagset = 0; + + for (i = 0; i < (int)(sizeof(flags)/sizeof(flags[0])); ++i) +#if HAVE_SUN_ACL + if (a_flags & flags[i].machine) +#else + if (acl_get_flag_np(opaque_fs, flags[i].machine)) +#endif + flagset |= flags[i].portable; + return flagset; +} + +static int +#if HAVE_SUN_ACL +acl_match(ace_t *ace, struct myacl_t *myacl) +#else +acl_match(acl_entry_t aclent, struct myacl_t *myacl) +#endif +{ +#if !HAVE_SUN_ACL +#if HAVE_DARWIN_ACL + void *q; + uid_t ugid; + int r, idtype; +#else + gid_t g, *gp; + uid_t u, *up; + acl_entry_type_t entry_type; +#endif /* !HAVE_DARWIN_ACL */ + acl_tag_t tag_type; + acl_permset_t opaque_ps; + acl_flagset_t opaque_fs; +#endif /* !HAVE_SUN_ACL */ + int perms; + +#if HAVE_SUN_ACL + perms = acl_permset_to_bitmap(ace->a_access_mask) | acl_flagset_to_bitmap(ace->a_flags); +#else + acl_get_tag_type(aclent, &tag_type); +#if !HAVE_DARWIN_ACL + acl_get_entry_type_np(aclent, &entry_type); +#endif + + /* translate the silly opaque permset to a bitmap */ + acl_get_permset(aclent, &opaque_ps); + acl_get_flagset_np(aclent, &opaque_fs); + perms = acl_permset_to_bitmap(opaque_ps) | acl_flagset_to_bitmap(opaque_fs); +#endif + if (perms != myacl->permset) + return (0); + +#if HAVE_SUN_ACL + switch (ace->a_type) { + case ACE_ACCESS_ALLOWED_ACE_TYPE: + if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_ALLOW) + return (0); + break; + case ACE_ACCESS_DENIED_ACE_TYPE: + if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_DENY) + return (0); + break; + case ACE_SYSTEM_AUDIT_ACE_TYPE: + if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_AUDIT) + return (0); + break; + case ACE_SYSTEM_ALARM_ACE_TYPE: + if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_ALARM) + return (0); + break; + default: + return (0); + } + + if (ace->a_flags & ACE_OWNER) { + if (myacl->tag != ARCHIVE_ENTRY_ACL_USER_OBJ) + return (0); + } else if (ace->a_flags & ACE_GROUP) { + if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP_OBJ) + return (0); + } else if (ace->a_flags & ACE_EVERYONE) { + if (myacl->tag != ARCHIVE_ENTRY_ACL_EVERYONE) + return (0); + } else if (ace->a_flags & ACE_IDENTIFIER_GROUP) { + if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP) + return (0); + if ((gid_t)myacl->qual != ace->a_who) + return (0); + } else { + if (myacl->tag != ARCHIVE_ENTRY_ACL_USER) + return (0); + if ((uid_t)myacl->qual != ace->a_who) + return (0); + } +#elif HAVE_DARWIN_ACL + r = 0; + switch (tag_type) { + case ACL_EXTENDED_ALLOW: + if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_ALLOW) + return (0); + break; + case ACL_EXTENDED_DENY: + if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_DENY) + return (0); + break; + default: + return (0); + } + q = acl_get_qualifier(aclent); + if (q == NULL) + return (0); + r = mbr_uuid_to_id((const unsigned char *)q, &ugid, &idtype); + acl_free(q); + if (r != 0) + return (0); + switch (idtype) { + case ID_TYPE_UID: + if (myacl->tag != ARCHIVE_ENTRY_ACL_USER) + return (0); + if ((uid_t)myacl->qual != ugid) + return (0); + break; + case ID_TYPE_GID: + if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP) + return (0); + if ((gid_t)myacl->qual != ugid) + return (0); + break; + default: + return (0); + } +#else /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */ + switch (entry_type) { + case ACL_ENTRY_TYPE_ALLOW: + if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_ALLOW) + return (0); + break; + case ACL_ENTRY_TYPE_DENY: + if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_DENY) + return (0); + break; + case ACL_ENTRY_TYPE_AUDIT: + if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_AUDIT) + return (0); + case ACL_ENTRY_TYPE_ALARM: + if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_ALARM) + return (0); + default: + return (0); + } + + switch (tag_type) { + case ACL_USER_OBJ: + if (myacl->tag != ARCHIVE_ENTRY_ACL_USER_OBJ) return (0); + break; + case ACL_USER: + if (myacl->tag != ARCHIVE_ENTRY_ACL_USER) + return (0); + up = acl_get_qualifier(aclent); + u = *up; + acl_free(up); + if ((uid_t)myacl->qual != u) + return (0); + break; + case ACL_GROUP_OBJ: + if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP_OBJ) return (0); + break; + case ACL_GROUP: + if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP) + return (0); + gp = acl_get_qualifier(aclent); + g = *gp; + acl_free(gp); + if ((gid_t)myacl->qual != g) + return (0); + break; + case ACL_MASK: + if (myacl->tag != ARCHIVE_ENTRY_ACL_MASK) return (0); + break; + case ACL_EVERYONE: + if (myacl->tag != ARCHIVE_ENTRY_ACL_EVERYONE) return (0); + break; + } +#endif /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */ + return (1); +} + +static void +compare_acls( +#if HAVE_SUN_ACL + acl_t *acl, +#else + acl_t acl, +#endif + struct myacl_t *myacls, const char *filename, int start, int end) +{ + int *marker; + int matched; + int i, n; +#if HAVE_SUN_ACL + int e; + ace_t *acl_entry; +#else + int entry_id = ACL_FIRST_ENTRY; + acl_entry_t acl_entry; +#endif + + n = end - start; + marker = malloc(sizeof(marker[0]) * (n + 1)); + for (i = 0; i < n; i++) + marker[i] = i + start; + /* Always include the first ACE. */ + if (start > 0) { + marker[n] = 0; + ++n; + } + + /* + * Iterate over acls in system acl object, try to match each + * one with an item in the myacls array. + */ +#if HAVE_SUN_ACL + for (e = 0; e < acl->acl_cnt; e++) +#elif HAVE_DARWIN_ACL + while (0 == acl_get_entry(acl, entry_id, &acl_entry)) +#else + while (1 == acl_get_entry(acl, entry_id, &acl_entry)) +#endif + { +#if HAVE_SUN_ACL + acl_entry = &((ace_t *)acl->acl_aclp)[e]; +#else + /* After the first time... */ + entry_id = ACL_NEXT_ENTRY; +#endif + /* Search for a matching entry (tag and qualifier) */ + for (i = 0, matched = 0; i < n && !matched; i++) { + if (acl_match(acl_entry, &myacls[marker[i]])) { + /* We found a match; remove it. */ + marker[i] = marker[n - 1]; + n--; + matched = 1; + } + } + + failure("ACL entry on file %s that shouldn't be there", + filename); + assert(matched == 1); + } + + /* Dump entries in the myacls array that weren't in the system acl. */ + for (i = 0; i < n; ++i) { + failure(" ACL entry %d missing from %s: " + "type=%#010x,permset=%#010x,tag=%d,qual=%d,name=``%s''\n", + marker[i], filename, + myacls[marker[i]].type, myacls[marker[i]].permset, + myacls[marker[i]].tag, myacls[marker[i]].qual, + myacls[marker[i]].name); + assert(0); /* Record this as a failure. */ + } + free(marker); +} + +static void +compare_entry_acls(struct archive_entry *ae, struct myacl_t *myacls, const char *filename, int start, int end) +{ + int *marker; + int matched; + int i, n; + int type, permset, tag, qual; + const char *name; + + /* Count ACL entries in myacls array and allocate an indirect array. */ + n = end - start; + marker = malloc(sizeof(marker[0]) * (n + 1)); + for (i = 0; i < n; i++) + marker[i] = i + start; + /* Always include the first ACE. */ + if (start > 0) { + marker[n] = 0; + ++n; + } + + /* + * Iterate over acls in entry, try to match each + * one with an item in the myacls array. + */ + assertEqualInt(n, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_NFS4)); + while (ARCHIVE_OK == archive_entry_acl_next(ae, + ARCHIVE_ENTRY_ACL_TYPE_NFS4, &type, &permset, &tag, &qual, &name)) { + + /* Search for a matching entry (tag and qualifier) */ + for (i = 0, matched = 0; i < n && !matched; i++) { + if (tag == myacls[marker[i]].tag + && qual == myacls[marker[i]].qual + && permset == myacls[marker[i]].permset + && type == myacls[marker[i]].type) { + /* We found a match; remove it. */ + marker[i] = marker[n - 1]; + n--; + matched = 1; + } + } + + failure("ACL entry on file that shouldn't be there: " + "type=%#010x,permset=%#010x,tag=%d,qual=%d", + type,permset,tag,qual); + assert(matched == 1); + } + + /* Dump entries in the myacls array that weren't in the system acl. */ + for (i = 0; i < n; ++i) { + failure(" ACL entry %d missing from %s: " + "type=%#010x,permset=%#010x,tag=%d,qual=%d,name=``%s''\n", + marker[i], filename, + myacls[marker[i]].type, myacls[marker[i]].permset, + myacls[marker[i]].tag, myacls[marker[i]].qual, + myacls[marker[i]].name); + assert(0); /* Record this as a failure. */ + } + free(marker); +} +#endif /* HAVE_NFS4_ACL */ + +/* + * Verify ACL restore-to-disk. This test is Platform-specific. + */ + +DEFINE_TEST(test_acl_platform_nfs4) +{ +#if !HAVE_NFS4_ACL + skipping("NFS4 ACLs are not supported on this platform"); +#else + char buff[64]; + struct stat st; + struct archive *a; + struct archive_entry *ae; + int i, n; + char *func; +#if HAVE_DARWIN_ACL /* On MacOS we skip trivial ACLs in some tests */ + const int regcnt = acls_reg_cnt - 4; + const int dircnt = acls_dir_cnt - 4; +#else + const int regcnt = acls_reg_cnt; + const int dircnt = acls_dir_cnt; +#endif +#if HAVE_SUN_ACL + acl_t *acl; +#else /* !HAVE_SUN_ACL */ +#if HAVE_DARWIN_ACL + acl_entry_t aclent; + acl_permset_t permset; + const uid_t uid = 1000; + uuid_t uuid; +#endif /* HAVE_DARWIN_ACL */ + acl_t acl; +#endif /* !HAVE_SUN_ACL */ + + /* + * First, do a quick manual set/read of ACL data to + * verify that the local filesystem does support ACLs. + * If it doesn't, we'll simply skip the remaining tests. + */ +#if HAVE_POSIX_ACL && HAVE_ACL_TYPE_NFS4 + acl = acl_from_text("owner@:rwxp::allow,group@:rwp:f:allow"); + failure("acl_from_text(): errno = %d (%s)", errno, strerror(errno)); + assert((void *)acl != NULL); +#elif HAVE_DARWIN_ACL + acl = acl_init(1); + assert((void *)acl != NULL); + assertEqualInt(0, acl_create_entry(&acl, &aclent)); + assertEqualInt(0, acl_set_tag_type(aclent, ACL_EXTENDED_ALLOW)); + assertEqualInt(0, acl_get_permset(aclent, &permset)); + assertEqualInt(0, acl_add_perm(permset, ACL_READ_DATA)); + assertEqualInt(0, acl_add_perm(permset, ACL_WRITE_DATA)); + assertEqualInt(0, acl_add_perm(permset, ACL_APPEND_DATA)); + assertEqualInt(0, acl_add_perm(permset, ACL_EXECUTE)); + assertEqualInt(0, acl_set_permset(aclent, permset)); + assertEqualInt(0, mbr_identifier_to_uuid(ID_TYPE_UID, &uid, + sizeof(uid_t), uuid)); + assertEqualInt(0, acl_set_qualifier(aclent, uuid)); +#endif + + /* Create a test dir and try to set an ACL on it. */ + if (!assertMakeDir("pretest", 0755)) { +#if !HAVE_SUN_ACL + acl_free(acl); +#endif + return; + } + +#if HAVE_SUN_ACL + func = "acl_get()"; + n = acl_get("pretest", 0, &acl); +#else + func = "acl_set_file()"; +#if HAVE_DARWIN_ACL + n = acl_set_file("pretest", ACL_TYPE_EXTENDED, acl); +#else + n = acl_set_file("pretest", ACL_TYPE_NFS4, acl); +#endif + acl_free(acl); +#endif + if (n != 0) { +#if HAVE_SUN_ACL + if (errno == ENOSYS) +#else + if (errno == EOPNOTSUPP || errno == EINVAL) +#endif + { + skipping("NFS4 ACL is not supported on this filesystem"); + return; + } + } + failure("%s: errno = %d (%s)", func, errno, strerror(errno)); + assertEqualInt(0, n); + +#if HAVE_SUN_ACL + if (acl->acl_type != ACE_T) { + acl_free(acl); + skipping("NFS4 ACL is not supported on this filesystem"); + return; + } + acl_free(acl); +#endif + + /* Create a write-to-disk object. */ + assert(NULL != (a = archive_write_disk_new())); + archive_write_disk_set_options(a, + ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_ACL); + + /* Populate an archive entry with some metadata, including ACL info */ + ae = archive_entry_new(); + assert(ae != NULL); + archive_entry_set_pathname(ae, "testall"); + archive_entry_set_filetype(ae, AE_IFREG); + archive_entry_set_perm(ae, 0654); + archive_entry_set_mtime(ae, 123456, 7890); + archive_entry_set_size(ae, 0); + set_acls(ae, acls_reg, 0, acls_reg_cnt); + + /* Write the entry to disk, including ACLs. */ + assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); + + /* Likewise for a dir. */ + archive_entry_set_pathname(ae, "dirall"); + archive_entry_set_filetype(ae, AE_IFDIR); + archive_entry_set_perm(ae, 0654); + archive_entry_set_mtime(ae, 123456, 7890); + set_acls(ae, acls_dir, 0, acls_dir_cnt); + assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); + + for (i = 0; i < acls_dir_cnt; ++i) { + sprintf(buff, "dir%d", i); + archive_entry_set_pathname(ae, buff); + archive_entry_set_filetype(ae, AE_IFDIR); + archive_entry_set_perm(ae, 0654); + archive_entry_set_mtime(ae, 123456 + i, 7891 + i); + set_acls(ae, acls_dir, i, i + 1); + assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); + } + + archive_entry_free(ae); + + /* Close the archive. */ + assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a)); + assertEqualInt(ARCHIVE_OK, archive_write_free(a)); + + /* Verify the data on disk. */ + assertEqualInt(0, stat("testall", &st)); + assertEqualInt(st.st_mtime, 123456); +#if HAVE_SUN_ACL + n = acl_get("testall", 0, &acl); + failure("acl_get(): errno = %d (%s)", errno, strerror(errno)); + assertEqualInt(0, n); +#else +#if HAVE_DARWIN_ACL + acl = acl_get_file("testall", ACL_TYPE_EXTENDED); +#else + acl = acl_get_file("testall", ACL_TYPE_NFS4); +#endif + failure("acl_get_file(): errno = %d (%s)", errno, strerror(errno)); + assert(acl != (acl_t)NULL); +#endif + compare_acls(acl, acls_reg, "testall", 0, regcnt); + acl_free(acl); + + /* Verify single-permission dirs on disk. */ + for (i = 0; i < dircnt; ++i) { + sprintf(buff, "dir%d", i); + assertEqualInt(0, stat(buff, &st)); + assertEqualInt(st.st_mtime, 123456 + i); +#if HAVE_SUN_ACL + n = acl_get(buff, 0, &acl); + failure("acl_get(): errno = %d (%s)", errno, strerror(errno)); + assertEqualInt(0, n); +#else +#if HAVE_DARWIN_ACL + acl = acl_get_file(buff, ACL_TYPE_EXTENDED); +#else + acl = acl_get_file(buff, ACL_TYPE_NFS4); +#endif + failure("acl_get_file(): errno = %d (%s)", errno, + strerror(errno)); + assert(acl != (acl_t)NULL); +#endif + compare_acls(acl, acls_dir, buff, i, i + 1); + acl_free(acl); + } + + /* Verify "dirall" on disk. */ + assertEqualInt(0, stat("dirall", &st)); + assertEqualInt(st.st_mtime, 123456); +#if HAVE_SUN_ACL + n = acl_get("dirall", 0, &acl); + failure("acl_get(): errno = %d (%s)", errno, strerror(errno)); + assertEqualInt(0, n); +#else +#if HAVE_DARWIN_ACL + acl = acl_get_file("dirall", ACL_TYPE_EXTENDED); +#else + acl = acl_get_file("dirall", ACL_TYPE_NFS4); +#endif + failure("acl_get_file(): errno = %d (%s)", errno, strerror(errno)); + assert(acl != (acl_t)NULL); +#endif + compare_acls(acl, acls_dir, "dirall", 0, dircnt); + acl_free(acl); + + /* Read and compare ACL via archive_read_disk */ + a = archive_read_disk_new(); + assert(a != NULL); + ae = archive_entry_new(); + assert(ae != NULL); + archive_entry_set_pathname(ae, "testall"); + assertEqualInt(ARCHIVE_OK, + archive_read_disk_entry_from_file(a, ae, -1, NULL)); + compare_entry_acls(ae, acls_reg, "testall", 0, acls_reg_cnt); + archive_entry_free(ae); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); + + /* Read and compare ACL via archive_read_disk */ + a = archive_read_disk_new(); + assert(a != NULL); + ae = archive_entry_new(); + assert(ae != NULL); + archive_entry_set_pathname(ae, "dirall"); + assertEqualInt(ARCHIVE_OK, + archive_read_disk_entry_from_file(a, ae, -1, NULL)); + compare_entry_acls(ae, acls_dir, "dirall", 0, acls_dir_cnt); + archive_entry_free(ae); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +#endif /* HAVE_NFS4_ACL */ +} diff --git a/contrib/libarchive/libarchive/test/test_acl_platform_posix1e.c b/contrib/libarchive/libarchive/test/test_acl_platform_posix1e.c new file mode 100644 index 0000000..f3e1722 --- /dev/null +++ b/contrib/libarchive/libarchive/test/test_acl_platform_posix1e.c @@ -0,0 +1,653 @@ +/*- + * Copyright (c) 2003-2008 Tim Kientzle + * Copyright (c) 2017 Martin Matuska + * 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(S) ``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(S) 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. + */ +#include "test.h" +__FBSDID("$FreeBSD: head/lib/libarchive/test/test_acl_freebsd.c 189427 2009-03-06 04:21:23Z kientzle $"); + +#if HAVE_POSIX_ACL || HAVE_SUN_ACL +#include +#if HAVE_ACL_GET_PERM +#include +#define ACL_GET_PERM acl_get_perm +#elif HAVE_ACL_GET_PERM_NP +#define ACL_GET_PERM acl_get_perm_np +#endif + +static struct archive_test_acl_t acls2[] = { + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0, + ARCHIVE_ENTRY_ACL_USER, 78, "user78" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0007, + ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, + ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_EXECUTE, + ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, + ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ | ARCHIVE_ENTRY_ACL_EXECUTE, + ARCHIVE_ENTRY_ACL_MASK, -1, "" }, +}; + +static int +#if HAVE_SUN_ACL +acl_entry_get_perm(aclent_t *aclent) +#else +acl_entry_get_perm(acl_entry_t aclent) +#endif +{ + int permset = 0; +#if HAVE_POSIX_ACL + acl_permset_t opaque_ps; +#endif + +#if HAVE_SUN_ACL + if (aclent->a_perm & 1) + permset |= ARCHIVE_ENTRY_ACL_EXECUTE; + if (aclent->a_perm & 2) + permset |= ARCHIVE_ENTRY_ACL_WRITE; + if (aclent->a_perm & 4) + permset |= ARCHIVE_ENTRY_ACL_READ; +#else + /* translate the silly opaque permset to a bitmap */ + acl_get_permset(aclent, &opaque_ps); + if (ACL_GET_PERM(opaque_ps, ACL_EXECUTE)) + permset |= ARCHIVE_ENTRY_ACL_EXECUTE; + if (ACL_GET_PERM(opaque_ps, ACL_WRITE)) + permset |= ARCHIVE_ENTRY_ACL_WRITE; + if (ACL_GET_PERM(opaque_ps, ACL_READ)) + permset |= ARCHIVE_ENTRY_ACL_READ; +#endif + return permset; +} + +#if 0 +static int +acl_get_specific_entry(acl_t acl, acl_tag_t requested_tag_type, int requested_tag) { + int entry_id = ACL_FIRST_ENTRY; + acl_entry_t acl_entry; + acl_tag_t acl_tag_type; + + while (1 == acl_get_entry(acl, entry_id, &acl_entry)) { + /* After the first time... */ + entry_id = ACL_NEXT_ENTRY; + + /* If this matches, return perm mask */ + acl_get_tag_type(acl_entry, &acl_tag_type); + if (acl_tag_type == requested_tag_type) { + switch (acl_tag_type) { + case ACL_USER_OBJ: + if ((uid_t)requested_tag == *(uid_t *)(acl_get_qualifier(acl_entry))) { + return acl_entry_get_perm(acl_entry); + } + break; + case ACL_GROUP_OBJ: + if ((gid_t)requested_tag == *(gid_t *)(acl_get_qualifier(acl_entry))) { + return acl_entry_get_perm(acl_entry); + } + break; + case ACL_USER: + case ACL_GROUP: + case ACL_OTHER: + return acl_entry_get_perm(acl_entry); + default: + failure("Unexpected ACL tag type"); + assert(0); + } + } + + + } + return -1; +} +#endif + +static int +#if HAVE_SUN_ACL +acl_match(aclent_t *aclent, struct archive_test_acl_t *myacl) +#else +acl_match(acl_entry_t aclent, struct archive_test_acl_t *myacl) +#endif +{ +#if HAVE_POSIX_ACL + gid_t g, *gp; + uid_t u, *up; + acl_tag_t tag_type; +#endif + + if (myacl->permset != acl_entry_get_perm(aclent)) + return (0); + +#if HAVE_SUN_ACL + switch (aclent->a_type) +#else + acl_get_tag_type(aclent, &tag_type); + switch (tag_type) +#endif + { +#if HAVE_SUN_ACL + case DEF_USER_OBJ: + case USER_OBJ: +#else + case ACL_USER_OBJ: +#endif + if (myacl->tag != ARCHIVE_ENTRY_ACL_USER_OBJ) return (0); + break; +#if HAVE_SUN_ACL + case DEF_USER: + case USER: +#else + case ACL_USER: +#endif + if (myacl->tag != ARCHIVE_ENTRY_ACL_USER) + return (0); +#if HAVE_SUN_ACL + if ((uid_t)myacl->qual != aclent->a_id) + return (0); +#else + up = acl_get_qualifier(aclent); + u = *up; + acl_free(up); + if ((uid_t)myacl->qual != u) + return (0); +#endif + break; +#if HAVE_SUN_ACL + case DEF_GROUP_OBJ: + case GROUP_OBJ: +#else + case ACL_GROUP_OBJ: +#endif + if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP_OBJ) return (0); + break; +#if HAVE_SUN_ACL + case DEF_GROUP: + case GROUP: +#else + case ACL_GROUP: +#endif + if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP) + return (0); +#if HAVE_SUN_ACL + if ((gid_t)myacl->qual != aclent->a_id) + return (0); +#else + gp = acl_get_qualifier(aclent); + g = *gp; + acl_free(gp); + if ((gid_t)myacl->qual != g) + return (0); +#endif + break; +#if HAVE_SUN_ACL + case DEF_CLASS_OBJ: + case CLASS_OBJ: +#else + case ACL_MASK: +#endif + if (myacl->tag != ARCHIVE_ENTRY_ACL_MASK) return (0); + break; +#if HAVE_SUN_ACL + case DEF_OTHER_OBJ: + case OTHER_OBJ: +#else + case ACL_OTHER: +#endif + if (myacl->tag != ARCHIVE_ENTRY_ACL_OTHER) return (0); + break; + } + return (1); +} + +static void +#if HAVE_SUN_ACL +compare_acls(acl_t *acl, struct archive_test_acl_t *myacls, int n) +#else +compare_acls(acl_t acl, struct archive_test_acl_t *myacls, int n) +#endif +{ + int *marker; + int matched; + int i; +#if HAVE_SUN_ACL + int e; + aclent_t *acl_entry; +#else + int entry_id = ACL_FIRST_ENTRY; + acl_entry_t acl_entry; +#endif + + /* Count ACL entries in myacls array and allocate an indirect array. */ + marker = malloc(sizeof(marker[0]) * n); + if (marker == NULL) + return; + for (i = 0; i < n; i++) + marker[i] = i; + + /* + * Iterate over acls in system acl object, try to match each + * one with an item in the myacls array. + */ +#if HAVE_SUN_ACL + for(e = 0; e < acl->acl_cnt; e++) { + acl_entry = &((aclent_t *)acl->acl_aclp)[e]; +#else + while (1 == acl_get_entry(acl, entry_id, &acl_entry)) { + /* After the first time... */ + entry_id = ACL_NEXT_ENTRY; +#endif + + /* Search for a matching entry (tag and qualifier) */ + for (i = 0, matched = 0; i < n && !matched; i++) { + if (acl_match(acl_entry, &myacls[marker[i]])) { + /* We found a match; remove it. */ + marker[i] = marker[n - 1]; + n--; + matched = 1; + } + } + + /* TODO: Print out more details in this case. */ + failure("ACL entry on file that shouldn't be there"); + assert(matched == 1); + } + + /* Dump entries in the myacls array that weren't in the system acl. */ + for (i = 0; i < n; ++i) { + failure(" ACL entry missing from file: " + "type=%#010x,permset=%#010x,tag=%d,qual=%d,name=``%s''\n", + myacls[marker[i]].type, myacls[marker[i]].permset, + myacls[marker[i]].tag, myacls[marker[i]].qual, + myacls[marker[i]].name); + assert(0); /* Record this as a failure. */ + } + free(marker); +} + +#endif + + +/* + * Verify ACL restore-to-disk. This test is Platform-specific. + */ + +DEFINE_TEST(test_acl_platform_posix1e_restore) +{ +#if !HAVE_SUN_ACL && !HAVE_POSIX_ACL + skipping("POSIX.1e ACLs are not supported on this platform"); +#else /* HAVE_SUN_ACL || HAVE_POSIX_ACL */ + struct stat st; + struct archive *a; + struct archive_entry *ae; + int n, fd; + char *func; +#if HAVE_SUN_ACL + acl_t *acl, *acl2; +#else + acl_t acl; +#endif + + /* + * First, do a quick manual set/read of ACL data to + * verify that the local filesystem does support ACLs. + * If it doesn't, we'll simply skip the remaining tests. + */ +#if HAVE_SUN_ACL + n = acl_fromtext("user::rwx,user:1:rw-,group::rwx,group:15:r-x,other:rwx,mask:rwx", &acl); + failure("acl_fromtext(): errno = %d (%s)", errno, strerror(errno)); + assertEqualInt(0, n); +#else + acl = acl_from_text("u::rwx,u:1:rw,g::rwx,g:15:rx,o::rwx,m::rwx"); + failure("acl_from_text(): errno = %d (%s)", errno, strerror(errno)); + assert((void *)acl != NULL); +#endif + + /* Create a test file and try ACL on it. */ + fd = open("pretest", O_WRONLY | O_CREAT | O_EXCL, 0777); + failure("Could not create test file?!"); + if (!assert(fd >= 0)) { + acl_free(acl); + return; + } + +#if HAVE_SUN_ACL + n = facl_get(fd, 0, &acl2); + if (n != 0) { + close(fd); + acl_free(acl); + } + if (errno == ENOSYS) { + skipping("POSIX.1e ACLs are not supported on this filesystem"); + return; + } + failure("facl_get(): errno = %d (%s)", errno, strerror(errno)); + assertEqualInt(0, n); + + if (acl2->acl_type != ACLENT_T) { + acl_free(acl2); + skipping("POSIX.1e ACLs are not supported on this filesystem"); + return; + } + acl_free(acl2); + + func = "facl_set()"; + n = facl_set(fd, acl); +#else + func = "acl_set_fd()"; + n = acl_set_fd(fd, acl); +#endif + acl_free(acl); + if (n != 0) { +#if HAVE_SUN_ACL + if (errno == ENOSYS) +#else + if (errno == EOPNOTSUPP || errno == EINVAL) +#endif + { + close(fd); + skipping("POSIX.1e ACLs are not supported on this filesystem"); + return; + } + } + failure("%s: errno = %d (%s)", func, errno, strerror(errno)); + assertEqualInt(0, n); + +#if HAVE_SUN_ACL + +#endif + close(fd); + + /* Create a write-to-disk object. */ + assert(NULL != (a = archive_write_disk_new())); + archive_write_disk_set_options(a, + ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_ACL); + + /* Populate an archive entry with some metadata, including ACL info */ + ae = archive_entry_new(); + assert(ae != NULL); + archive_entry_set_pathname(ae, "test0"); + archive_entry_set_mtime(ae, 123456, 7890); + archive_entry_set_size(ae, 0); + archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); + assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); + archive_entry_free(ae); + + /* Close the archive. */ + assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a)); + assertEqualInt(ARCHIVE_OK, archive_write_free(a)); + + /* Verify the data on disk. */ + assertEqualInt(0, stat("test0", &st)); + assertEqualInt(st.st_mtime, 123456); +#if HAVE_SUN_ACL + n = acl_get("test0", 0, &acl); + failure("acl_get(): errno = %d (%s)", errno, strerror(errno)); + assertEqualInt(0, n); +#else + acl = acl_get_file("test0", ACL_TYPE_ACCESS); + failure("acl_get_file(): errno = %d (%s)", errno, strerror(errno)); + assert(acl != (acl_t)NULL); +#endif + compare_acls(acl, acls2, sizeof(acls2)/sizeof(acls2[0])); + acl_free(acl); +#endif /* HAVE_SUN_ACL || HAVE_POSIX_ACL */ +} + +/* + * Verify ACL read-from-disk. This test is Platform-specific. + */ +DEFINE_TEST(test_acl_platform_posix1e_read) +{ +#if !HAVE_SUN_ACL && !HAVE_POSIX_ACL + skipping("POSIX.1e ACLs are not supported on this platform"); +#else + struct archive *a; + struct archive_entry *ae; + int n, fd, flags, dflags; + char *func, *acl_text; + const char *acl1_text, *acl2_text, *acl3_text; +#if HAVE_SUN_ACL + acl_t *acl, *acl1, *acl2, *acl3; +#else + acl_t acl1, acl2, acl3; +#endif + + /* + * Manually construct a directory and two files with + * different ACLs. This also serves to verify that ACLs + * are supported on the local filesystem. + */ + + /* Create a test file f1 with acl1 */ +#if HAVE_SUN_ACL + acl1_text = "user::rwx," + "group::rwx," + "other:rwx," + "user:1:rw-," + "group:15:r-x," + "mask:rwx"; + n = acl_fromtext(acl1_text, &acl1); + failure("acl_fromtext(): errno = %d (%s)", errno, strerror(errno)); + assertEqualInt(0, n); +#else + acl1_text = "user::rwx\n" + "group::rwx\n" + "other::rwx\n" + "user:1:rw-\n" + "group:15:r-x\n" + "mask::rwx"; + acl1 = acl_from_text(acl1_text); + failure("acl_from_text(): errno = %d (%s)", errno, strerror(errno)); + assert((void *)acl1 != NULL); +#endif + fd = open("f1", O_WRONLY | O_CREAT | O_EXCL, 0777); + failure("Could not create test file?!"); + if (!assert(fd >= 0)) { + acl_free(acl1); + return; + } +#if HAVE_SUN_ACL + /* Check if Solars filesystem supports POSIX.1e ACLs */ + n = facl_get(fd, 0, &acl); + if (n != 0) + close(fd); + if (n != 0 && errno == ENOSYS) { + acl_free(acl1); + skipping("POSIX.1e ACLs are not supported on this filesystem"); + return; + } + failure("facl_get(): errno = %d (%s)", errno, strerror(errno)); + assertEqualInt(0, n); + + if (acl->acl_type != ACLENT_T) { + acl_free(acl); + acl_free(acl1); + close(fd); + skipping("POSIX.1e ACLs are not supported on this filesystem"); + return; + } + + func = "facl_set()"; + n = facl_set(fd, acl1); +#else + func = "acl_set_fd()"; + n = acl_set_fd(fd, acl1); +#endif + acl_free(acl1); + + if (n != 0) { +#if HAVE_SUN_ACL + if (errno == ENOSYS) +#else + if (errno == EOPNOTSUPP || errno == EINVAL) +#endif + { + close(fd); + skipping("POSIX.1e ACLs are not supported on this filesystem"); + return; + } + } + failure("%s: errno = %d (%s)", func, errno, strerror(errno)); + assertEqualInt(0, n); + + close(fd); + + assertMakeDir("d", 0700); + + /* + * Create file d/f1 with acl2 + * + * This differs from acl1 in the u:1: and g:15: permissions. + * + * This file deliberately has the same name but a different ACL. + * Github Issue #777 explains how libarchive's directory traversal + * did not always correctly enter directories before attempting + * to read ACLs, resulting in reading the ACL from a like-named + * file in the wrong directory. + */ +#if HAVE_SUN_ACL + acl2_text = "user::rwx," + "group::rwx," + "other:---," + "user:1:r--," + "group:15:r--," + "mask:rwx"; + n = acl_fromtext(acl2_text, &acl2); + failure("acl_fromtext(): errno = %d (%s)", errno, strerror(errno)); + assertEqualInt(0, n); +#else + acl2_text = "user::rwx\n" + "group::rwx\n" + "other::---\n" + "user:1:r--\n" + "group:15:r--\n" + "mask::rwx"; + acl2 = acl_from_text(acl2_text); + failure("acl_from_text(): errno = %d (%s)", errno, strerror(errno)); + assert((void *)acl2 != NULL); +#endif + fd = open("d/f1", O_WRONLY | O_CREAT | O_EXCL, 0777); + failure("Could not create test file?!"); + if (!assert(fd >= 0)) { + acl_free(acl2); + return; + } +#if HAVE_SUN_ACL + func = "facl_set()"; + n = facl_set(fd, acl2); +#else + func = "acl_set_fd()"; + n = acl_set_fd(fd, acl2); +#endif + acl_free(acl2); + if (n != 0) + close(fd); + failure("%s: errno = %d (%s)", func, errno, strerror(errno)); + assertEqualInt(0, n); + close(fd); + + /* Create directory d2 with default ACLs */ + assertMakeDir("d2", 0755); + +#if HAVE_SUN_ACL + acl3_text = "user::rwx," + "group::r-x," + "other:r-x," + "user:2:r--," + "group:16:-w-," + "mask:rwx," + "default:user::rwx," + "default:user:1:r--," + "default:group::r-x," + "default:group:15:r--," + "default:mask:rwx," + "default:other:r-x"; + n = acl_fromtext(acl3_text, &acl3); + failure("acl_fromtext(): errno = %d (%s)", errno, strerror(errno)); + assertEqualInt(0, n); +#else + acl3_text = "user::rwx\n" + "user:1:r--\n" + "group::r-x\n" + "group:15:r--\n" + "mask::rwx\n" + "other::r-x"; + acl3 = acl_from_text(acl3_text); + failure("acl_from_text(): errno = %d (%s)", errno, strerror(errno)); + assert((void *)acl3 != NULL); +#endif + +#if HAVE_SUN_ACL + func = "acl_set()"; + n = acl_set("d2", acl3); +#else + func = "acl_set_file()"; + n = acl_set_file("d2", ACL_TYPE_DEFAULT, acl3); +#endif + acl_free(acl3); + + failure("%s: errno = %d (%s)", func, errno, strerror(errno)); + assertEqualInt(0, n); + + /* Create a read-from-disk object. */ + assert(NULL != (a = archive_read_disk_new())); + assertEqualIntA(a, ARCHIVE_OK, archive_read_disk_open(a, ".")); + assert(NULL != (ae = archive_entry_new())); + +#if HAVE_SUN_ACL + flags = ARCHIVE_ENTRY_ACL_TYPE_POSIX1E + | ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA + | ARCHIVE_ENTRY_ACL_STYLE_SOLARIS; + dflags = flags; +#else + flags = ARCHIVE_ENTRY_ACL_TYPE_ACCESS; + dflags = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT; +#endif + + /* Walk the dir until we see both of the files */ + while (ARCHIVE_OK == archive_read_next_header2(a, ae)) { + archive_read_disk_descend(a); + if (strcmp(archive_entry_pathname(ae), "./f1") == 0) { + acl_text = archive_entry_acl_to_text(ae, NULL, flags); + assertEqualString(acl_text, acl1_text); + free(acl_text); + } else if (strcmp(archive_entry_pathname(ae), "./d/f1") == 0) { + acl_text = archive_entry_acl_to_text(ae, NULL, flags); + assertEqualString(acl_text, acl2_text); + free(acl_text); + } else if (strcmp(archive_entry_pathname(ae), "./d2") == 0) { + acl_text = archive_entry_acl_to_text(ae, NULL, dflags); + assertEqualString(acl_text, acl3_text); + free(acl_text); + } + } + + archive_entry_free(ae); + assertEqualInt(ARCHIVE_OK, archive_free(a)); +#endif +} diff --git a/contrib/libarchive/libarchive/test/test_acl_posix1e.c b/contrib/libarchive/libarchive/test/test_acl_posix1e.c index 9984d44..01167da 100644 --- a/contrib/libarchive/libarchive/test/test_acl_posix1e.c +++ b/contrib/libarchive/libarchive/test/test_acl_posix1e.c @@ -27,21 +27,14 @@ __FBSDID("$FreeBSD: src/lib/libarchive/test/test_acl_basic.c,v 1.6 2008/10/19 00 /* * Exercise the system-independent portion of the ACL support. - * Check that archive_entry objects can save and restore POSIX.1e-style ACL data. + * Check that archive_entry objects can save and restore POSIX.1e-style + * ACL data. * * This should work on all systems, regardless of whether local * filesystems support ACLs or not. */ -struct acl_t { - int type; /* Type of ACL: "access" or "default" */ - int permset; /* Permissions for this class of users. */ - int tag; /* Owner, User, Owning group, group, other, etc. */ - int qual; /* GID or UID of user/group, depending on tag. */ - const char *name; /* Name of user/group, depending on tag. */ -}; - -static struct acl_t acls0[] = { +static struct archive_test_acl_t acls0[] = { { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" }, { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, @@ -50,7 +43,7 @@ static struct acl_t acls0[] = { ARCHIVE_ENTRY_ACL_OTHER, 0, "" }, }; -static struct acl_t acls1[] = { +static struct archive_test_acl_t acls1[] = { { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, @@ -61,7 +54,7 @@ static struct acl_t acls1[] = { ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, }; -static struct acl_t acls2[] = { +static struct archive_test_acl_t acls2[] = { { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ, ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, @@ -80,7 +73,7 @@ static struct acl_t acls2[] = { * NFS4 entry types; attempts to set these on top of POSIX.1e * attributes should fail. */ -static struct acl_t acls_nfs4[] = { +static struct archive_test_acl_t acls_nfs4[] = { /* NFS4 types */ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ, ARCHIVE_ENTRY_ACL_USER, 78, "" }, @@ -104,106 +97,6 @@ static struct acl_t acls_nfs4[] = { ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, }; -static void -set_acls(struct archive_entry *ae, struct acl_t *acls, int n) -{ - int i; - - archive_entry_acl_clear(ae); - for (i = 0; i < n; i++) { - archive_entry_acl_add_entry(ae, - acls[i].type, acls[i].permset, acls[i].tag, acls[i].qual, - acls[i].name); - } -} - -static int -acl_match(struct acl_t *acl, int type, int permset, int tag, int qual, const char *name) -{ - if (type != acl->type) - return (0); - if (permset != acl->permset) - return (0); - if (tag != acl->tag) - return (0); - if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) - return (1); - if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) - return (1); - if (tag == ARCHIVE_ENTRY_ACL_OTHER) - return (1); - if (qual != acl->qual) - return (0); - if (name == NULL) { - if (acl->name == NULL || acl->name[0] == '\0') - return (1); - return (0); - } - if (acl->name == NULL) { - if (name[0] == '\0') - return (1); - return (0); - } - return (0 == strcmp(name, acl->name)); -} - -static void -compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode) -{ - int *marker = malloc(sizeof(marker[0]) * n); - int i; - int r; - int type, permset, tag, qual; - int matched; - const char *name; - - for (i = 0; i < n; i++) - marker[i] = i; - - while (0 == (r = archive_entry_acl_next(ae, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name))) { - for (i = 0, matched = 0; i < n && !matched; i++) { - if (acl_match(&acls[marker[i]], type, permset, - tag, qual, name)) { - /* We found a match; remove it. */ - marker[i] = marker[n - 1]; - n--; - matched = 1; - } - } - if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) { - if (!matched) printf("No match for user_obj perm\n"); - failure("USER_OBJ permset (%02o) != user mode (%02o)", - permset, 07 & (mode >> 6)); - assert((permset << 6) == (mode & 0700)); - } else if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) { - if (!matched) printf("No match for group_obj perm\n"); - failure("GROUP_OBJ permset %02o != group mode %02o", - permset, 07 & (mode >> 3)); - assert((permset << 3) == (mode & 0070)); - } else if (tag == ARCHIVE_ENTRY_ACL_OTHER) { - if (!matched) printf("No match for other perm\n"); - failure("OTHER permset (%02o) != other mode (%02o)", - permset, mode & 07); - assert((permset << 0) == (mode & 0007)); - } else { - failure("Could not find match for ACL " - "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", - type, permset, tag, qual, name); - assert(matched == 1); - } - } - assertEqualInt(ARCHIVE_EOF, r); - assert((mode_t)(mode & 0777) == (archive_entry_mode(ae) & 0777)); - failure("Could not find match for ACL " - "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", - acls[marker[0]].type, acls[marker[0]].permset, - acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name); - assert(n == 0); /* Number of ACLs not matched should == 0 */ - free(marker); -} - DEFINE_TEST(test_acl_posix1e) { struct archive_entry *ae; @@ -223,7 +116,7 @@ DEFINE_TEST(test_acl_posix1e) * triggering unnecessary extensions. It's better to identify * trivial ACLs at the point they are being read from disk. */ - set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); + archive_test_set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); failure("Basic ACLs shouldn't be stored as extended ACLs"); assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); failure("Basic ACLs should set mode to 0142, not %04o", @@ -232,19 +125,28 @@ DEFINE_TEST(test_acl_posix1e) /* With any extended ACL entry, we should read back a full set. */ - set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); + archive_test_set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); failure("One extended ACL should flag all ACLs to be returned."); + + /* Check that entry contains only POSIX.1e types */ + assert((archive_entry_acl_types(ae) & + ARCHIVE_ENTRY_ACL_TYPE_NFS4) == 0); + assert((archive_entry_acl_types(ae) & + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0); + assert(4 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), 0142); + archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), + ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0142); failure("Basic ACLs should set mode to 0142, not %04o", archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0142); /* A more extensive set of ACLs. */ - set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); + archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); assertEqualInt(6, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), 0543); + archive_test_compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), + ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0543); failure("Basic ACLs should set mode to 0543, not %04o", archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0543); @@ -253,7 +155,7 @@ DEFINE_TEST(test_acl_posix1e) * Check that clearing ACLs gets rid of them all by repeating * the first test. */ - set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); + archive_test_set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); failure("Basic ACLs shouldn't be stored as extended ACLs"); assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); failure("Basic ACLs should set mode to 0142, not %04o", @@ -264,9 +166,9 @@ DEFINE_TEST(test_acl_posix1e) * Different types of malformed ACL entries that should * fail when added to existing POSIX.1e ACLs. */ - set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); + archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); for (i = 0; i < (int)(sizeof(acls_nfs4)/sizeof(acls_nfs4[0])); ++i) { - struct acl_t *p = &acls_nfs4[i]; + struct archive_test_acl_t *p = &acls_nfs4[i]; failure("Malformed ACL test #%d", i); assertEqualInt(ARCHIVE_FAILED, archive_entry_acl_add_entry(ae, diff --git a/contrib/libarchive/libarchive/test/test_acl_text.c b/contrib/libarchive/libarchive/test/test_acl_text.c new file mode 100644 index 0000000..23d991e --- /dev/null +++ b/contrib/libarchive/libarchive/test/test_acl_text.c @@ -0,0 +1,462 @@ +/*- + * Copyright (c) 2016 Martin Matuska + * 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(S) ``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(S) 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. + */ +#include "test.h" +__FBSDID("$FreeBSD$"); + +/* + * Test converting ACLs to text, both wide and non-wide + * + * This should work on all systems, regardless of whether local + * filesystems support ACLs or not. + */ + +static struct archive_test_acl_t acls0[] = { + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ | + ARCHIVE_ENTRY_ACL_WRITE, + ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_USER, 100, "user100" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0, + ARCHIVE_ENTRY_ACL_USER, 1000, "user1000" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ | + ARCHIVE_ENTRY_ACL_WRITE, + ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, + ARCHIVE_ENTRY_ACL_READ | + ARCHIVE_ENTRY_ACL_EXECUTE, + ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, 0, + ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_USER, 101, "user101"}, + { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, + ARCHIVE_ENTRY_ACL_EXECUTE, + ARCHIVE_ENTRY_ACL_GROUP, 79, "group79" }, +}; + +static struct archive_test_acl_t acls1[] = { + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_WRITE_OWNER, + ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, + { ARCHIVE_ENTRY_ACL_TYPE_DENY, + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_DELETE_CHILD | + ARCHIVE_ENTRY_ACL_DELETE | + ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT | + ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT | + ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY | + ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, + ARCHIVE_ENTRY_ACL_USER, 101, "user101" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, + ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_WRITE_ACL | + ARCHIVE_ENTRY_ACL_WRITE_OWNER, + ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_EVERYONE, 0, "" }, +}; + +const char* acltext[] = { + "user::rwx\n" + "group::r-x\n" + "other::r-x\n" + "user:user100:r-x\n" + "user:user1000:---\n" + "group:group78:rwx\n" + "default:user::r-x\n" + "default:group::r-x\n" + "default:other::---\n" + "default:user:user101:r-x\n" + "default:group:group79:--x", + + "user::rwx\n" + "group::r-x\n" + "other::r-x\n" + "user:user100:r-x:100\n" + "user:user1000:---:1000\n" + "group:group78:rwx:78\n" + "default:user::r-x\n" + "default:group::r-x\n" + "default:other::---\n" + "default:user:user101:r-x:101\n" + "default:group:group79:--x:79", + + "u::rwx\n" + "g::r-x\n" + "o::r-x\n" + "u:user100:r-x:100\n" + "u:user1000:---:1000\n" + "g:group78:rwx:78\n" + "d:user::r-x\n" + "d:group::r-x\n" + "d:other::---\n" + "d:user:user101:r-x:101\n" + "d:group:group79:--x:79", + + "user::rwx\n" + "group::r-x\n" + "other::r-x\n" + "user:user100:r-x\n" + "user:user1000:---\n" + "group:group78:rwx", + + "user::rwx," + "group::r-x," + "other::r-x," + "user:user100:r-x," + "user:user1000:---," + "group:group78:rwx", + + "user::rwx\n" + "group::r-x\n" + "other::r-x\n" + "user:user100:r-x:100\n" + "user:user1000:---:1000\n" + "group:group78:rwx:78", + + "user::r-x\n" + "group::r-x\n" + "other::---\n" + "user:user101:r-x\n" + "group:group79:--x", + + "user::r-x\n" + "group::r-x\n" + "other::---\n" + "user:user101:r-x:101\n" + "group:group79:--x:79", + + "default:user::r-x\n" + "default:group::r-x\n" + "default:other::---\n" + "default:user:user101:r-x\n" + "default:group:group79:--x", + + "user:user77:rw-p--a-R-c-o-:-------:allow\n" + "user:user101:-w-pdD--------:fdin---:deny\n" + "group:group78:r-----a-R-c---:------I:allow\n" + "owner@:rwxp--aARWcCo-:-------:allow\n" + "group@:rw-p--a-R-c---:-------:allow\n" + "everyone@:r-----a-R-c--s:-------:allow", + + "user:user77:rw-p--a-R-c-o-:-------:allow:77\n" + "user:user101:-w-pdD--------:fdin---:deny:101\n" + "group:group78:r-----a-R-c---:------I:allow:78\n" + "owner@:rwxp--aARWcCo-:-------:allow\n" + "group@:rw-p--a-R-c---:-------:allow\n" + "everyone@:r-----a-R-c--s:-------:allow" +}; + +static wchar_t * +convert_s_to_ws(const char *s) +{ + size_t len; + wchar_t *ws = NULL; + + if (s != NULL) { + len = strlen(s) + 1; + ws = malloc(len * sizeof(wchar_t)); + assert(mbstowcs(ws, s, len) != (size_t)-1); + } + + return (ws); +} + +static void +compare_acl_text(struct archive_entry *ae, int flags, const char *s) +{ + char *text; + wchar_t *wtext; + wchar_t *ws; + ssize_t slen; + + ws = convert_s_to_ws(s); + + text = archive_entry_acl_to_text(ae, &slen, flags); + assertEqualString(text, s); + if (text != NULL) + assertEqualInt(strlen(text), slen); + wtext = archive_entry_acl_to_text_w(ae, &slen, flags); + assertEqualWString(wtext, ws); + if (wtext != NULL) { + assertEqualInt(wcslen(wtext), slen); + } + free(text); + free(wtext); + free(ws); +} + +DEFINE_TEST(test_acl_from_text) +{ + struct archive_entry *ae; + wchar_t *ws = NULL; + + /* Create an empty archive_entry. */ + assert((ae = archive_entry_new()) != NULL); + + /* 1a. Read POSIX.1e access ACLs from text */ + assertEqualInt(ARCHIVE_OK, + archive_entry_acl_from_text(ae, acltext[5], + ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); + archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]), + ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0755); + assertEqualInt(6, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); + + /* 1b. Now read POSIX.1e default ACLs and append them */ + assertEqualInt(ARCHIVE_OK, + archive_entry_acl_from_text(ae, acltext[7], + ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)); + archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]), + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, 0755); + assertEqualInt(11, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E)); + archive_entry_acl_clear(ae); + + /* 1a and 1b with wide strings */ + ws = convert_s_to_ws(acltext[5]); + + assertEqualInt(ARCHIVE_OK, + archive_entry_acl_from_text_w(ae, ws, + ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); + archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]), + ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0755); + assertEqualInt(6, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); + + free(ws); + ws = convert_s_to_ws(acltext[7]); + + assertEqualInt(ARCHIVE_OK, + archive_entry_acl_from_text_w(ae, ws, + ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)); + archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]), + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, 0755); + assertEqualInt(11, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E)); + archive_entry_acl_clear(ae); + + /* 2. Read POSIX.1e default ACLs from text */ + assertEqualInt(ARCHIVE_OK, + archive_entry_acl_from_text(ae, acltext[7], + ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)); + archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]), + ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, 0); + assertEqualInt(5, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)); + archive_entry_acl_clear(ae); + + /* ws is still acltext[7] */ + assertEqualInt(ARCHIVE_OK, + archive_entry_acl_from_text_w(ae, ws, + ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)); + archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]), + ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, 0); + assertEqualInt(5, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)); + archive_entry_acl_clear(ae); + + /* 3. Read POSIX.1e access and default ACLs from text */ + assertEqualInt(ARCHIVE_OK, + archive_entry_acl_from_text(ae, acltext[1], + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E)); + archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]), + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, 0755); + assertEqualInt(11, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E)); + archive_entry_acl_clear(ae); + + free(ws); + ws = convert_s_to_ws(acltext[1]); + assertEqualInt(ARCHIVE_OK, + archive_entry_acl_from_text_w(ae, ws, + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E)); + archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]), + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, 0755); + assertEqualInt(11, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E)); + archive_entry_acl_clear(ae); + + /* 4. Read POSIX.1e access and default ACLs from text (short form) */ + assertEqualInt(ARCHIVE_OK, + archive_entry_acl_from_text(ae, acltext[2], + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E)); + archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]), + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, 0755); + assertEqualInt(11, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E)); + archive_entry_acl_clear(ae); + + free(ws); + ws = convert_s_to_ws(acltext[2]); + assertEqualInt(ARCHIVE_OK, + archive_entry_acl_from_text_w(ae, ws, + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E)); + archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]), + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, 0755); + assertEqualInt(11, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_POSIX1E)); + archive_entry_acl_clear(ae); + + /* 5. Read NFSv4 ACLs from text */ + assertEqualInt(ARCHIVE_OK, + archive_entry_acl_from_text(ae, acltext[10], + ARCHIVE_ENTRY_ACL_TYPE_NFS4)); + archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), + ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0); + assertEqualInt(6, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_NFS4)); + archive_entry_acl_clear(ae); + + free(ws); + ws = convert_s_to_ws(acltext[10]); + + assertEqualInt(ARCHIVE_OK, + archive_entry_acl_from_text_w(ae, ws, + ARCHIVE_ENTRY_ACL_TYPE_NFS4)); + archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), + ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0); + assertEqualInt(6, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_NFS4)); + archive_entry_acl_clear(ae); + + free(ws); + archive_entry_free(ae); +} + +DEFINE_TEST(test_acl_to_text) +{ + struct archive_entry *ae; + + /* Create an empty archive_entry. */ + assert((ae = archive_entry_new()) != NULL); + + /* Write POSIX.1e ACLs */ + archive_test_set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); + + /* No flags should give output like getfacl(1) on linux */ + compare_acl_text(ae, 0, acltext[0]); + + /* This should give the same output as previous test */ + compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS | + ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, acltext[0]); + + /* This should give the same output as previous two tests */ + compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS | + ARCHIVE_ENTRY_ACL_TYPE_DEFAULT | + ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT, acltext[0]); + + /* POSIX.1e access and default ACLs with appended ID */ + compare_acl_text(ae, ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID, acltext[1]); + + /* POSIX.1e access acls only, like getfacl(1) on FreeBSD */ + compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, acltext[3]); + + /* POSIX.1e access acls separated with comma */ + compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS | + ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA, + acltext[4]); + + /* POSIX.1e access acls with appended user or group ID */ + compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS | + ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID, acltext[5]); + + /* POSIX.1e default acls */ + compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, acltext[6]); + + /* POSIX.1e default acls with appended user or group ID */ + compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT | + ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID, acltext[7]); + + /* POSIX.1e default acls prefixed with default: */ + compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT | + ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT, acltext[8]); + + /* Write NFSv4 ACLs */ + archive_test_set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); + + /* NFSv4 ACLs like getfacl(1) on FreeBSD */ + compare_acl_text(ae, 0, acltext[9]); + + /* NFSv4 ACLs like "getfacl -i" on FreeBSD */ + compare_acl_text(ae, ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID, acltext[10]); + + archive_entry_free(ae); +} diff --git a/contrib/libarchive/libarchive/test/test_archive_read_add_passphrase.c b/contrib/libarchive/libarchive/test/test_archive_read_add_passphrase.c index 68dec10..0ce5a76 100644 --- a/contrib/libarchive/libarchive/test/test_archive_read_add_passphrase.c +++ b/contrib/libarchive/libarchive/test/test_archive_read_add_passphrase.c @@ -191,7 +191,7 @@ DEFINE_TEST(test_archive_read_add_passphrase_set_callback3) /* Fist call, we should get "passCallBack" as a passphrase. */ assertEqualString("passCallBack", __archive_read_next_passphrase(ar)); __archive_read_reset_passphrase(ar); - /* After reset passphrase, we should get "passCallBack"passphrase. */ + /* After reset passphrase, we should get "passCallBack" passphrase. */ assertEqualString("passCallBack", __archive_read_next_passphrase(ar)); /* Second call, we should get NULL which means all the passphrases * are passed already. */ diff --git a/contrib/libarchive/libarchive/test/test_archive_string.c b/contrib/libarchive/libarchive/test/test_archive_string.c index 9e3f907..7fa743b 100644 --- a/contrib/libarchive/libarchive/test/test_archive_string.c +++ b/contrib/libarchive/libarchive/test/test_archive_string.c @@ -67,6 +67,8 @@ test_archive_string_ensure(void) assert(&s == archive_string_ensure(&s, EXTENT + 1)); assertNonNULLString(0, 2 * EXTENT, s); + + archive_string_free(&s); } static void @@ -92,6 +94,8 @@ test_archive_strcat(void) /* non-empty target, non-empty source */ assert(&s == archive_strcat(&s, "baz")); assertExactString(8, EXTENT, "fubarbaz", s); + + archive_string_free(&s); } static void @@ -109,6 +113,8 @@ test_archive_strappend_char(void) /* non-empty target */ archive_strappend_char(&s, 'Y'); assertExactString(2, EXTENT, "XY", s); + + archive_string_free(&s); } /* archive_strnXXX() tests focus on length handling. @@ -134,6 +140,8 @@ test_archive_strncat(void) /* long read is ok too! */ assert(&s == archive_strncat(&s, "snafu", 8)); assertExactString(13, EXTENT, "snafubarsnafu", s); + + archive_string_free(&s); } static void @@ -155,6 +163,8 @@ test_archive_strncpy(void) /* long read is ok too! */ assert(&s == archive_strncpy(&s, "snafu", 8)); assertExactString(5, EXTENT, "snafu", s); + + archive_string_free(&s); } static void @@ -176,6 +186,8 @@ test_archive_strcpy(void) /* dirty target, empty source */ assert(&s == archive_strcpy(&s, "")); assertExactString(0, EXTENT, "", s); + + archive_string_free(&s); } static void @@ -222,6 +234,11 @@ test_archive_string_concat(void) archive_string_concat(&t, &s); assertExactString(5, EXTENT, "snafu", s); assertExactString(5, EXTENT, "snafu", t); + + archive_string_free(&v); + archive_string_free(&u); + archive_string_free(&t); + archive_string_free(&s); } static void @@ -274,6 +291,11 @@ test_archive_string_copy(void) archive_string_copy(&t, &s); assertExactString(5, EXTENT, "fubar", s); assertExactString(5, EXTENT, "fubar", t); + + archive_string_free(&v); + archive_string_free(&u); + archive_string_free(&t); + archive_string_free(&s); } static void @@ -328,6 +350,8 @@ test_archive_string_sprintf(void) archive_string_empty(&s); archive_string_sprintf(&s, "%d", 1234567890); assertExactString(10, 8 * EXTENT, "1234567890", s); + + archive_string_free(&s); } DEFINE_TEST(test_archive_string) diff --git a/contrib/libarchive/libarchive/test/test_compat_gtar.c b/contrib/libarchive/libarchive/test/test_compat_gtar.c index b33e6ab..975b824 100644 --- a/contrib/libarchive/libarchive/test/test_compat_gtar.c +++ b/contrib/libarchive/libarchive/test/test_compat_gtar.c @@ -142,6 +142,8 @@ test_compat_gtar_2(void) assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_NONE); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR); + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } DEFINE_TEST(test_compat_gtar) diff --git a/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.c b/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.c index d4654d0..3d063c1 100644 --- a/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.c +++ b/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2003-2009 Tim Kientzle + * Copyright (c) 2016 Martin Matuska * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,101 +27,239 @@ __FBSDID("$FreeBSD$"); /* - * Exercise support for reading Solaris-style ACL data - * from tar archives. + * Verify reading entries with POSIX.1e and NFSv4 ACLs from archives created + * with Solaris tar. * - * This should work on all systems, regardless of whether local - * filesystems support ACLs or not. + * This should work on all systems, regardless of whether local filesystems + * support ACLs or not. */ +static struct archive_test_acl_t acls0[] = { + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE | + ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, + ARCHIVE_ENTRY_ACL_USER, 71, "lp" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_USER, 666, "666" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_USER, 1000, "1000" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_MASK, -1, ""}, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, +}; + +static struct archive_test_acl_t acls1[] = { + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_USER, 2, "bin" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_GROUP, 3, "sys" }, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_MASK, -1, ""}, + { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0, + ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, +}; + +static struct archive_test_acl_t acls2[] = { + { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_USER_OBJ, -1 ,"" }, + { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_USER, 2, "bin" }, + { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_GROUP, 3, "sys" }, + { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ, + ARCHIVE_ENTRY_ACL_MASK, -1, ""}, + { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, 0, + ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, +}; + +static struct archive_test_acl_t acls3[] = { + { ARCHIVE_ENTRY_ACL_TYPE_DENY, + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_WRITE_ACL | + ARCHIVE_ENTRY_ACL_WRITE_OWNER | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_GROUP, 12, "daemon" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_GROUP, 2, "bin" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_USER, 4, "adm" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_WRITE_ACL | + ARCHIVE_ENTRY_ACL_WRITE_OWNER | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_EVERYONE, 0, "" }, +}; + +static struct archive_test_acl_t acls4[] = { + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_WRITE_ACL | + ARCHIVE_ENTRY_ACL_WRITE_OWNER | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE | + ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT | + ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT | + ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, + ARCHIVE_ENTRY_ACL_USER, 1100, "1100" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE | + ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT | + ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, + ARCHIVE_ENTRY_ACL_GROUP, 4, "adm" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_WRITE_DATA | + ARCHIVE_ENTRY_ACL_APPEND_DATA | + ARCHIVE_ENTRY_ACL_DELETE_CHILD | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_WRITE_ACL | + ARCHIVE_ENTRY_ACL_WRITE_OWNER | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_EXECUTE | + ARCHIVE_ENTRY_ACL_READ_DATA | + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" }, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, + ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES | + ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | + ARCHIVE_ENTRY_ACL_READ_ACL | + ARCHIVE_ENTRY_ACL_SYNCHRONIZE, + ARCHIVE_ENTRY_ACL_EVERYONE, 0, "" }, +}; + DEFINE_TEST(test_compat_solaris_tar_acl) { + char name[] = "test_compat_solaris_tar_acl.tar"; struct archive *a; struct archive_entry *ae; - const char *reference1 = "test_compat_solaris_tar_acl.tar"; - int type, permset, tag, qual; - const char *name; - /* Sample file generated on Solaris 10 */ - extract_reference_file(reference1); + /* Read archive file */ assert(NULL != (a = archive_read_new())); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_filter_all(a)); - assertA(0 == archive_read_open_filename(a, reference1, 512)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); + extract_reference_file(name); + assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, + 10240)); - /* Archive has 1 entry with some ACLs set on it. */ + /* First item has access ACLs */ assertA(0 == archive_read_next_header(a, &ae)); + failure("One extended ACL should flag all ACLs to be returned."); + assertEqualInt(7, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); + archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]), + ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0644); failure("Basic ACLs should set mode to 0644, not %04o", archive_entry_mode(ae)&0777); - assertEqualInt((archive_entry_mode(ae) & 0777), 0644); - assertEqualInt(7, archive_entry_acl_reset(ae, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type); - assertEqualInt(006, permset); - assertEqualInt(ARCHIVE_ENTRY_ACL_USER_OBJ, tag); - assertEqualInt(-1, qual); - assert(name == NULL); - - assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type); - assertEqualInt(004, permset); - assertEqualInt(ARCHIVE_ENTRY_ACL_GROUP_OBJ, tag); - assertEqualInt(-1, qual); - assert(name == NULL); + assert((archive_entry_mode(ae) & 0777) == 0644); - assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type); - assertEqualInt(004, permset); - assertEqualInt(ARCHIVE_ENTRY_ACL_OTHER, tag); - assertEqualInt(-1, qual); - assert(name == NULL); - - assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type); - assertEqualInt(001, permset); - assertEqualInt(ARCHIVE_ENTRY_ACL_USER, tag); - assertEqualInt(71, qual); - assertEqualString(name, "lp"); - - assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type); - assertEqualInt(004, permset); - assertEqualInt(ARCHIVE_ENTRY_ACL_USER, tag); - assertEqualInt(666, qual); - assertEqualString(name, "666"); - - assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type); - assertEqualInt(007, permset); - assertEqualInt(ARCHIVE_ENTRY_ACL_USER, tag); - assertEqualInt(1000, qual); - assertEqualString(name, "trasz"); + /* Second item has default and access ACLs */ + assertA(0 == archive_read_next_header(a, &ae)); + assertEqualInt(6, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); + archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), + ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0750); + failure("Basic ACLs should set mode to 0750, not %04o", + archive_entry_mode(ae)&0777); + assert((archive_entry_mode(ae) & 0777) == 0750); + assertEqualInt(6, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)); + archive_test_compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), + ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, 0750); - assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type); - assertEqualInt(004, permset); - assertEqualInt(ARCHIVE_ENTRY_ACL_MASK, tag); - assertEqualInt(-1, qual); - assertEqualString(name, NULL); + /* Third item has NFS4 ACLs */ + assertA(0 == archive_read_next_header(a, &ae)); + assertEqualInt(6, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_NFS4)); + archive_test_compare_acls(ae, acls3, sizeof(acls3)/sizeof(acls3[0]), + ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0); - assertEqualInt(ARCHIVE_EOF, archive_entry_acl_next(ae, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); + /* Fourth item has NFS4 ACLs and inheritance flags */ + assertA(0 == archive_read_next_header(a, &ae)); + assertEqualInt(5, archive_entry_acl_reset(ae, + ARCHIVE_ENTRY_ACL_TYPE_NFS4)); + archive_test_compare_acls(ae, acls4, sizeof(acls4)/sizeof(acls0[4]), + ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0); /* Close the archive. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); diff --git a/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.tar.uu b/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.tar.uu index 229b335..028dd61 100644 --- a/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.tar.uu +++ b/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.tar.uu @@ -1,61 +1,163 @@ -$FreeBSD$ -begin 644 test_acl_solaris.tar -M9FEL92UW:71H+7!O#HW,2QU#HW,2QU#HQ,#`P+&=R;W5P.CIR+2TL;6%S:SIR+69I;&4M=VET:"UP -M;W-I>"UA8VQS```````````````````````````````````````````````` -M```````````````````````````````````````````````````````````P -M,#`P-C0T`#`P,#$W-3``,#`P,#`P,``P,#`P,#`P,#`P,``Q,3$W-#8P-#$U -M-P`P,#$U,30T`#`````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````=7-T87(`,#!T@`````````````` -M`````````````````````')O;W0````````````````````````````````` -M````,#`P,#(Q,``P,#`P,#$P```````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -H```````````````````````````````````````````````````````` -` +M.C$P,# Z"UA8VQS +M P +M,# P-C0T # P,#$W-3 ,# P,# P, P,# P,# P,# P, Q,3$W-#8P-#$U +M-P P,#$T,#

"QU"QO=&AE"QD969A=6QT=7-E' M+2TM+2TM+2US.BTM+2TM+2TZ86QL;W' M+6%!4E=C0V]S.BTM+2TM+2TZ9&5N>3HQ,BQG +M6]N94 Z+2TM+2TM82U2+6,M+7,Z +M+2TM+2TM+3IA;&QO=P 4 +M +M "HUP@( -, ,S P,# P-0!U' M1&%!4E=C +M0V]S.BTM+2TM+2TZ86QL;W"TM+6$M4BUC+2US.BTM+2TM +M+2TZ86QL;W"TM+2TM+2TM+2TM.BTM+2TM+2TZ9&5N>3HW."QG3HW."QU'`M+6%!4E=C0V]S.BTM+2TM+2TZ86QL;W'`M+6%!4E=C +M+2US.BTM+2TM+2TZ86QL;W"TM+6$M4BUC+2US.BTM +M+2TM+2TZ86QL;W<*```````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````````!D:7(Q+P`````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M,#`P,#type) - return (0); - if (permset != acl->permset) - return (0); - if (tag != acl->tag) - return (0); - if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) - return (1); - if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) - return (1); - if (tag == ARCHIVE_ENTRY_ACL_OTHER) - return (1); - if (tag == ARCHIVE_ENTRY_ACL_MASK) - return (1); - if (name == NULL) - return (acl->name == NULL || acl->name[0] == '\0'); - if (acl->name == NULL) - return (name == NULL || name[0] == '\0'); - return (0 == strcmp(name, acl->name)); -} - -static void -compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode, - int want_type) -{ - int *marker = malloc(sizeof(marker[0]) * n); - int i; - int r; - int type, permset, tag, qual; - int matched; - const char *name; - - for (i = 0; i < n; i++) - marker[i] = i; - - while (0 == (r = archive_entry_acl_next(ae, want_type, - &type, &permset, &tag, &qual, &name))) { - for (i = 0, matched = 0; i < n && !matched; i++) { - if (acl_match(&acls[marker[i]], type, permset, - tag, name)) { - /* We found a match; remove it. */ - marker[i] = marker[n - 1]; - n--; - matched = 1; - } - } - if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) { - if (!matched) printf("No match for user_obj perm\n"); - if (want_type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) { - failure("USER_OBJ permset (%02o) != user mode (%02o)", - permset, 07 & (mode >> 6)); - assert((permset << 6) == (mode & 0700)); - } - } else if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) { - if (!matched) printf("No match for group_obj perm\n"); - if (want_type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) { - failure("GROUP_OBJ permset %02o != group mode %02o", - permset, 07 & (mode >> 3)); - assert((permset << 3) == (mode & 0070)); - } - } else if (tag == ARCHIVE_ENTRY_ACL_OTHER) { - if (!matched) printf("No match for other perm\n"); - if (want_type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) { - failure("OTHER permset (%02o) != other mode (%02o)", - permset, mode & 07); - assert((permset << 0) == (mode & 0007)); - } - } else if (tag != ARCHIVE_ENTRY_ACL_MASK) { - failure("Could not find match for ACL " - "(type=%d,permset=%d,tag=%d,name=``%s'')", - type, permset, tag, name); - assert(matched == 1); - } - } - assertEqualInt(ARCHIVE_EOF, r); - assert((mode_t)(mode & 0777) == (archive_entry_mode(ae) & 0777)); - failure("Could not find match for ACL " - "(type=%d,permset=%d,tag=%d,name=``%s'')", - acls[marker[0]].type, acls[marker[0]].permset, - acls[marker[0]].tag, acls[marker[0]].name); - assert(n == 0); /* Number of ACLs not matched should == 0 */ - free(marker); -} - -DEFINE_TEST(test_compat_star_acl_posix1e) -{ - char name[] = "test_compat_star_acl_posix1e.tar"; - struct archive *a; - struct archive_entry *ae; - - /* Read archive file */ - assert(NULL != (a = archive_read_new())); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); - extract_reference_file(name); - assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240)); - - /* First item has a few ACLs */ - assertA(0 == archive_read_next_header(a, &ae)); - failure("One extended ACL should flag all ACLs to be returned."); - assertEqualInt(5, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]), 0142, ARCHIVE_ENTRY_ACL_TYPE_ACCESS); - failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); - assert((archive_entry_mode(ae) & 0777) == 0142); - - /* Second item has pretty extensive ACLs */ - assertA(0 == archive_read_next_header(a, &ae)); - assertEqualInt(7, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), 0543, ARCHIVE_ENTRY_ACL_TYPE_ACCESS); - failure("Basic ACLs should set mode to 0543, not %04o", - archive_entry_mode(ae)&0777); - assert((archive_entry_mode(ae) & 0777) == 0543); - - /* Third item has default ACLs */ - assertA(0 == archive_read_next_header(a, &ae)); - assertEqualInt(6, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)); - compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), 0142, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT); - failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); - assert((archive_entry_mode(ae) & 0777) == 0142); - - /* Close the archive. */ - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_free(a)); -} diff --git a/contrib/libarchive/libarchive/test/test_compat_uudecode.c b/contrib/libarchive/libarchive/test/test_compat_uudecode.c index 95b1c9a..cfb17c8 100644 --- a/contrib/libarchive/libarchive/test/test_compat_uudecode.c +++ b/contrib/libarchive/libarchive/test/test_compat_uudecode.c @@ -40,7 +40,7 @@ static char archive_data[] = { }; /* - * Compatibility: uudecode command ignores junk data placed ater the "end" + * Compatibility: uudecode command ignores junk data placed after the "end" * marker. */ DEFINE_TEST(test_compat_uudecode) diff --git a/contrib/libarchive/libarchive/test/test_fuzz.c b/contrib/libarchive/libarchive/test/test_fuzz.c index b70a415a..e896f60 100644 --- a/contrib/libarchive/libarchive/test/test_fuzz.c +++ b/contrib/libarchive/libarchive/test/test_fuzz.c @@ -406,10 +406,12 @@ DEFINE_TEST(test_fuzz_tar) "test_read_format_tar_empty_filename.tar", NULL }; +#if HAVE_LIBLZO2 && HAVE_LZO_LZO1X_H && HAVE_LZO_LZOCONF_H static const char *fileset9[] = { "test_compat_lzop_1.tar.lzo", NULL }; +#endif static const struct files filesets[] = { {0, fileset1}, /* Exercise bzip2 decompressor. */ {1, fileset1}, @@ -420,7 +422,9 @@ DEFINE_TEST(test_fuzz_tar) {0, fileset6}, /* Exercise xz decompressor. */ {0, fileset7}, {0, fileset8}, +#if HAVE_LIBLZO2 && HAVE_LZO_LZO1X_H && HAVE_LZO_LZOCONF_H {0, fileset9}, /* Exercise lzo decompressor. */ +#endif {1, NULL} }; test_fuzz(filesets); diff --git a/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c b/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c index 31eb76b..c9aca8f 100644 --- a/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c +++ b/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c @@ -1320,11 +1320,13 @@ test_callbacks(void) assertUtimes("cb", 886622, 0, 886622, 0); assert((ae = archive_entry_new()) != NULL); - if (assert((a = archive_read_disk_new()) != NULL)) { + assert((a = archive_read_disk_new()) != NULL); + if (a == NULL) { archive_entry_free(ae); return; } - if (assert((m = archive_match_new()) != NULL)) { + assert((m = archive_match_new()) != NULL); + if (m == NULL) { archive_entry_free(ae); archive_read_free(a); archive_match_free(m); @@ -1377,6 +1379,10 @@ test_callbacks(void) /* Close the disk object. */ assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + /* Reset name filter */ + assertEqualIntA(a, ARCHIVE_OK, + archive_read_disk_set_matching(a, NULL, NULL, NULL)); + /* * Test2: Traversals with a metadata filter. */ @@ -1394,7 +1400,7 @@ test_callbacks(void) while (file_count--) { archive_entry_clear(ae); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header2(a, ae)); - failure("File 'cb/f1' should be exclueded"); + failure("File 'cb/f1' should be excluded"); assert(strcmp(archive_entry_pathname(ae), "cb/f1") != 0); if (strcmp(archive_entry_pathname(ae), "cb") == 0) { assertEqualInt(archive_entry_filetype(ae), AE_IFDIR); diff --git a/contrib/libarchive/libarchive/test/test_read_filter_lzop.c b/contrib/libarchive/libarchive/test/test_read_filter_lzop.c index 86a5e6e..acce6a4 100644 --- a/contrib/libarchive/libarchive/test/test_read_filter_lzop.c +++ b/contrib/libarchive/libarchive/test/test_read_filter_lzop.c @@ -39,13 +39,16 @@ DEFINE_TEST(test_read_filter_lzop) assert((a = archive_read_new()) != NULL); r = archive_read_support_filter_lzop(a); if (r != ARCHIVE_OK) { - if (r == ARCHIVE_WARN && !canLzop()) { + if (!canLzop()) { assertEqualInt(ARCHIVE_OK, archive_read_free(a)); skipping("lzop compression is not supported " "on this platform"); - } else + return; + } else if (r != ARCHIVE_WARN) { assertEqualIntA(a, ARCHIVE_OK, r); - return; + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); + return; + } } assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); assertEqualIntA(a, ARCHIVE_OK, diff --git a/contrib/libarchive/libarchive/test/test_read_filter_lzop_multiple_parts.c b/contrib/libarchive/libarchive/test/test_read_filter_lzop_multiple_parts.c index 3b0febb..82eaf35 100644 --- a/contrib/libarchive/libarchive/test/test_read_filter_lzop_multiple_parts.c +++ b/contrib/libarchive/libarchive/test/test_read_filter_lzop_multiple_parts.c @@ -36,12 +36,16 @@ DEFINE_TEST(test_read_filter_lzop_multiple_parts) assert((a = archive_read_new()) != NULL); r = archive_read_support_filter_lzop(a); if (r != ARCHIVE_OK) { - if (r == ARCHIVE_WARN && !canLzop()) { - assertEqualInt(ARCHIVE_OK, archive_read_free(a)); + if (!canLzop()) { skipping("lzop compression is not supported " "on this platform"); + } else if (r == ARCHIVE_WARN) { + skipping("lzop multiple parts decoding is not " + "supported via external program"); + } else assertEqualIntA(a, ARCHIVE_OK, r); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); return; } assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); diff --git a/contrib/libarchive/libarchive/test/test_read_format_7zip.c b/contrib/libarchive/libarchive/test/test_read_format_7zip.c index 14447de..1d1e4c7 100644 --- a/contrib/libarchive/libarchive/test/test_read_format_7zip.c +++ b/contrib/libarchive/libarchive/test/test_read_format_7zip.c @@ -688,7 +688,7 @@ test_symname() assertEqualInt(32, archive_read_data(a, buff, sizeof(buff))); assertEqualMem(buff, "hellohellohello\nhellohellohello\n", 32); - /* Verify symbolic-linke symlinkfile. */ + /* Verify symbolic-link symlinkfile. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualInt((AE_IFLNK | 0755), archive_entry_mode(ae)); assertEqualString("symlinkfile", archive_entry_pathname(ae)); diff --git a/contrib/libarchive/libarchive/test/test_read_format_cpio_afio.c b/contrib/libarchive/libarchive/test/test_read_format_cpio_afio.c index 16065eb..95d3171 100644 --- a/contrib/libarchive/libarchive/test/test_read_format_cpio_afio.c +++ b/contrib/libarchive/libarchive/test/test_read_format_cpio_afio.c @@ -27,7 +27,7 @@ __FBSDID("$FreeBSD$"); /* -ecute the following to rebuild the data for this program: +execute the following to rebuild the data for this program: tail -n +33 test_read_format_cpio_afio.c | /bin/sh # How to make a sample data. diff --git a/contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c b/contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c index 3cb30a4..bff385c 100644 --- a/contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c +++ b/contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c @@ -26,7 +26,7 @@ __FBSDID("$FreeBSD$"); /* -PLEASE use old cdrtools; mkisofs verion is 2.01. +PLEASE use old cdrtools; mkisofs version is 2.01. This version mkisofs made wrong "SL" System Use Entry of RRIP. Execute the following command to rebuild the data for this program: diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip.c b/contrib/libarchive/libarchive/test/test_read_format_zip.c index 62a49ba..29b3fc2 100644 --- a/contrib/libarchive/libarchive/test/test_read_format_zip.c +++ b/contrib/libarchive/libarchive/test/test_read_format_zip.c @@ -126,6 +126,7 @@ test_basic(void) assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 31)); verify_basic(a, 0); + free(p); } /* @@ -195,6 +196,7 @@ test_info_zip_ux(void) assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 108)); verify_info_zip_ux(a, 0); + free(p); } /* @@ -258,6 +260,7 @@ test_extract_length_at_end(void) assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 108)); verify_extract_length_at_end(a, 0); + free(p); } static void @@ -294,6 +297,8 @@ test_symlink(void) assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); + + free(p); } DEFINE_TEST(test_read_format_zip) diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_comment_stored.c b/contrib/libarchive/libarchive/test/test_read_format_zip_comment_stored.c index d2b935d..b92b288 100644 --- a/contrib/libarchive/libarchive/test/test_read_format_zip_comment_stored.c +++ b/contrib/libarchive/libarchive/test/test_read_format_zip_comment_stored.c @@ -63,6 +63,8 @@ verify(const char *refname) assertEqualInt(archive_entry_is_encrypted(ae), 0); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); + + free(p); } DEFINE_TEST(test_read_format_zip_comment_stored) diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_filename.c b/contrib/libarchive/libarchive/test/test_read_format_zip_filename.c index 93ba09b..4dd2e8a 100644 --- a/contrib/libarchive/libarchive/test/test_read_format_zip_filename.c +++ b/contrib/libarchive/libarchive/test/test_read_format_zip_filename.c @@ -1116,7 +1116,7 @@ cleanup: * - the filename of second file is stored in UTF-8. * * Whenever hdrcharset option is specified, we will correctly read the - * filename of sencod file, which is stored in UTF-8. + * filename of second file, which is stored in UTF-8. */ DEFINE_TEST(test_read_format_zip_filename_KOI8R_UTF8_2) diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_mac_metadata.c b/contrib/libarchive/libarchive/test/test_read_format_zip_mac_metadata.c index 97aa427..99b7012 100644 --- a/contrib/libarchive/libarchive/test/test_read_format_zip_mac_metadata.c +++ b/contrib/libarchive/libarchive/test/test_read_format_zip_mac_metadata.c @@ -112,4 +112,6 @@ DEFINE_TEST(test_read_format_zip_mac_metadata) assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); + + free(p); } diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_malformed.c b/contrib/libarchive/libarchive/test/test_read_format_zip_malformed.c index 2327d91..e14a3f5 100644 --- a/contrib/libarchive/libarchive/test/test_read_format_zip_malformed.c +++ b/contrib/libarchive/libarchive/test/test_read_format_zip_malformed.c @@ -53,6 +53,7 @@ test_malformed1(void) assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 31)); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); + free(p); } DEFINE_TEST(test_read_format_zip_malformed) diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_nested.c b/contrib/libarchive/libarchive/test/test_read_format_zip_nested.c index 6830afb..5f6edf2 100644 --- a/contrib/libarchive/libarchive/test/test_read_format_zip_nested.c +++ b/contrib/libarchive/libarchive/test/test_read_format_zip_nested.c @@ -65,6 +65,8 @@ DEFINE_TEST(test_read_format_zip_nested) assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); + free(p); + /* Inspect inner Zip. */ assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_padded.c b/contrib/libarchive/libarchive/test/test_read_format_zip_padded.c index dae88ab..2094eca 100644 --- a/contrib/libarchive/libarchive/test/test_read_format_zip_padded.c +++ b/contrib/libarchive/libarchive/test/test_read_format_zip_padded.c @@ -53,6 +53,8 @@ verify_padded_archive(const char *refname) assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); + + free(p); } /* diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_sfx.c b/contrib/libarchive/libarchive/test/test_read_format_zip_sfx.c index d5992d3..dc76ef9 100644 --- a/contrib/libarchive/libarchive/test/test_read_format_zip_sfx.c +++ b/contrib/libarchive/libarchive/test/test_read_format_zip_sfx.c @@ -60,4 +60,6 @@ DEFINE_TEST(test_read_format_zip_sfx) assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); + + free(p); } diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_traditional_encryption_data.c b/contrib/libarchive/libarchive/test/test_read_format_zip_traditional_encryption_data.c index 2700be1..3052615 100644 --- a/contrib/libarchive/libarchive/test/test_read_format_zip_traditional_encryption_data.c +++ b/contrib/libarchive/libarchive/test/test_read_format_zip_traditional_encryption_data.c @@ -28,7 +28,7 @@ __FBSDID("$FreeBSD$"); DEFINE_TEST(test_read_format_zip_traditional_encryption_data) { - /* This file is password protected (Traditional PKWARE Enctypted). + /* This file is password protected (Traditional PKWARE Encrypted). The headers are NOT encrypted. Password is "12345678". */ const char *refname = "test_read_format_zip_traditional_encryption_data.zip"; @@ -36,7 +36,7 @@ DEFINE_TEST(test_read_format_zip_traditional_encryption_data) struct archive *a; char buff[512]; - /* Check if running system has cryptographic functionarity. */ + /* Check if running system has cryptographic functionality. */ assert((a = archive_write_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a)); assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_none(a)); diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes.c b/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes.c index 082337d..cc1e311 100644 --- a/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes.c +++ b/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes.c @@ -33,7 +33,7 @@ test_winzip_aes(const char *refname, int need_libz) struct archive *a; char buff[512]; - /* Check if running system has cryptographic functionarity. */ + /* Check if running system has cryptographic functionality. */ assert((a = archive_write_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a)); assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_none(a)); diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes_large.c b/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes_large.c index a40d5cf..6c40ae7 100644 --- a/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes_large.c +++ b/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes_large.c @@ -34,7 +34,7 @@ DEFINE_TEST(test_read_format_zip_winzip_aes256_large) char buff[512]; - /* Check if running system has cryptographic functionarity. */ + /* Check if running system has cryptographic functionality. */ assert((a = archive_write_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a)); assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_none(a)); diff --git a/contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.c b/contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.c new file mode 100644 index 0000000..7554f6d --- /dev/null +++ b/contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.c @@ -0,0 +1,70 @@ +/*- + * Copyright (c) 2016 IBM Corporation + * Copyright (c) 2003-2007 Tim Kientzle + * + * 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(S) ``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(S) 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. + * + * This test case's code has been derived from test_entry.c + */ +#include "test.h" + +DEFINE_TEST(test_schily_xattr_pax) +{ + struct archive *a; + struct archive_entry *ae; + const char *refname = "test_read_pax_schily_xattr.tar"; + const char *xname; /* For xattr tests. */ + const void *xval; /* For xattr tests. */ + size_t xsize; /* For xattr tests. */ + const char *string, *array; + + assert((a = archive_read_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); + + extract_reference_file(refname); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_open_filename(a, refname, 10240)); + + assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt(2, archive_entry_xattr_count(ae)); + assertEqualInt(2, archive_entry_xattr_reset(ae)); + + assertEqualInt(0, archive_entry_xattr_next(ae, &xname, &xval, &xsize)); + assertEqualString(xname, "security.selinux"); + string = "system_u:object_r:unlabeled_t:s0"; + assertEqualString(xval, string); + /* the xattr's value also contains the terminating \0 */ + assertEqualInt((int)xsize, strlen(string) + 1); + + assertEqualInt(0, archive_entry_xattr_next(ae, &xname, &xval, &xsize)); + assertEqualString(xname, "security.ima"); + assertEqualInt((int)xsize, 265); + /* we only compare the first 12 bytes */ + array = "\x03\x02\x04\xb0\xe9\xd6\x79\x01\x00\x2b\xad\x1e"; + assertEqualMem(xval, array, 12); + + /* Close the archive. */ + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} diff --git a/contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.tar.uu b/contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.tar.uu new file mode 100644 index 0000000..52f7a8f --- /dev/null +++ b/contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.tar.uu @@ -0,0 +1,231 @@ +begin 644 test_schily_xattr_pax.tar +M+B]087A(96%D97)S+C$U,C4O8V]N9F9I;&5S```````````````````````` +M```````````````````````````````````````````````````````````` +M`````````````#`P,#`V-#0`,#`P,#`P,``P,#`P,#`P`#`P,#`P,#`P-C0W +M`#$R-S$R,C$P-3`V`#`Q,C4V-@`@>``````````````````````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````!UW6X5O?Y6: +M9^':P2MZR[4)$@W?)B6GX0U@<,0M%6YNMO%OG+IS%/.< +M,"A(N&S.F9]=!*5=\).X."2$GUGJ,0C:@+G#$M_E8UQP,LU-G(8IKW^K^<8* +M*3_.N0'%8.^$8S$`D9XOF+DK<<)U34U'_"O5/22YS96QI;G5X +M/7-Y libarchive_test'. */ diff --git a/contrib/libarchive/libarchive/test/test_write_disk_secure746.c b/contrib/libarchive/libarchive/test/test_write_disk_secure746.c index 460aafe..5ce1fd9 100644 --- a/contrib/libarchive/libarchive/test/test_write_disk_secure746.c +++ b/contrib/libarchive/libarchive/test/test_write_disk_secure746.c @@ -72,6 +72,9 @@ DEFINE_TEST(test_write_disk_secure746a) /* Verify that target file contents are unchanged. */ assertTextFileContents("unmodified", "../target/foo"); + + assertEqualIntA(a, ARCHIVE_FATAL, archive_write_close(a)); + archive_write_free(a); #endif } diff --git a/contrib/libarchive/libarchive/test/test_write_filter_lz4.c b/contrib/libarchive/libarchive/test/test_write_filter_lz4.c index a043698..4f2135a 100644 --- a/contrib/libarchive/libarchive/test/test_write_filter_lz4.c +++ b/contrib/libarchive/libarchive/test/test_write_filter_lz4.c @@ -56,6 +56,7 @@ DEFINE_TEST(test_write_filter_lz4) } else { assertEqualInt(ARCHIVE_OK, r); } + assertEqualInt(ARCHIVE_OK, archive_write_free(a)); buffsize = 2000000; assert(NULL != (buff = (char *)malloc(buffsize))); @@ -299,6 +300,7 @@ test_options(const char *options) } else { assertEqualInt(ARCHIVE_OK, r); } + assertEqualInt(ARCHIVE_OK, archive_write_free(a)); buffsize = 2000000; assert(NULL != (buff = (char *)malloc(buffsize))); diff --git a/contrib/libarchive/libarchive/test/test_write_filter_lzop.c b/contrib/libarchive/libarchive/test/test_write_filter_lzop.c index a32932c..92db7bf 100644 --- a/contrib/libarchive/libarchive/test/test_write_filter_lzop.c +++ b/contrib/libarchive/libarchive/test/test_write_filter_lzop.c @@ -43,12 +43,12 @@ DEFINE_TEST(test_write_filter_lzop) assert((a = archive_write_new()) != NULL); r = archive_write_add_filter_lzop(a); + assertEqualInt(ARCHIVE_OK, archive_write_free(a)); if (r != ARCHIVE_OK) { if (canLzop() && r == ARCHIVE_WARN) use_prog = 1; else { skipping("lzop writing not supported on this platform"); - assertEqualInt(ARCHIVE_OK, archive_write_free(a)); return; } } @@ -92,7 +92,7 @@ DEFINE_TEST(test_write_filter_lzop) assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); r = archive_read_support_filter_lzop(a); - if (r == ARCHIVE_WARN) { + if (r == ARCHIVE_WARN && !use_prog) { skipping("Can't verify lzop writing by reading back;" " lzop reading not fully supported on this platform"); } else { @@ -212,7 +212,7 @@ DEFINE_TEST(test_write_filter_lzop) assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); r = archive_read_support_filter_lzop(a); - if (r == ARCHIVE_WARN) { + if (r == ARCHIVE_WARN && !use_prog) { skipping("lzop reading not fully supported on this platform"); } else { assertEqualIntA(a, ARCHIVE_OK, diff --git a/contrib/libarchive/libarchive/test/test_write_format_iso9660.c b/contrib/libarchive/libarchive/test/test_write_format_iso9660.c index ee6db6f..e4e98bb 100644 --- a/contrib/libarchive/libarchive/test/test_write_format_iso9660.c +++ b/contrib/libarchive/libarchive/test/test_write_format_iso9660.c @@ -719,7 +719,7 @@ DEFINE_TEST(test_write_format_iso9660) assertEqualInt(5, archive_entry_ctime(ae)); assert(archive_entry_mtime_is_set(ae)); assertEqualInt(5, archive_entry_mtime(ae)); - /* Trim lngname to 64 characters. */ + /* Trim longname to 64 characters. */ longname[64] = '\0'; assertEqualString(longname, archive_entry_pathname(ae)); assert((AE_IFREG | 0400) == archive_entry_mode(ae)); diff --git a/contrib/libarchive/libarchive/test/test_write_format_iso9660_zisofs.c b/contrib/libarchive/libarchive/test/test_write_format_iso9660_zisofs.c index 136255b..2140ed8 100644 --- a/contrib/libarchive/libarchive/test/test_write_format_iso9660_zisofs.c +++ b/contrib/libarchive/libarchive/test/test_write_format_iso9660_zisofs.c @@ -25,7 +25,7 @@ #include "test.h" /* - * Check that a "zisofs" ISO 9660 imaeg is correctly created. + * Check that a "zisofs" ISO 9660 image is correctly created. */ static const unsigned char primary_id[] = { diff --git a/contrib/libarchive/libarchive/test/test_write_format_zip_large.c b/contrib/libarchive/libarchive/test/test_write_format_zip_large.c index d73dd62..88788b5 100644 --- a/contrib/libarchive/libarchive/test/test_write_format_zip_large.c +++ b/contrib/libarchive/libarchive/test/test_write_format_zip_large.c @@ -470,5 +470,6 @@ DEFINE_TEST(test_write_format_zip_large) assertEqualMem(cd_start, "PK\001\002", 4); fileblocks_free(fileblocks); + free(buff); free(nulldata); } diff --git a/contrib/libarchive/libarchive/test/test_write_format_zip_zip64.c b/contrib/libarchive/libarchive/test/test_write_format_zip_zip64.c index b83aeab..c5f00a2 100644 --- a/contrib/libarchive/libarchive/test/test_write_format_zip_zip64.c +++ b/contrib/libarchive/libarchive/test/test_write_format_zip_zip64.c @@ -49,6 +49,8 @@ verify_zip_filesize(uint64_t size, int expected) archive_entry_set_size(ae, size); assertEqualInt(expected, archive_write_header(a, ae)); + archive_entry_free(ae); + /* Don't actually write 4GB! ;-) */ assertEqualIntA(a, ARCHIVE_OK, archive_write_free(a)); } diff --git a/contrib/libarchive/libarchive/xxhash.c b/contrib/libarchive/libarchive/xxhash.c index d7f8e96..6f5ba52 100644 --- a/contrib/libarchive/libarchive/xxhash.c +++ b/contrib/libarchive/libarchive/xxhash.c @@ -29,10 +29,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. You can contact the author at : - xxHash source repository : http://code.google.com/p/xxhash/ */ +#include "archive_platform.h" + #include #include -#include "archive_platform.h" #include "archive_xxhash.h" #ifdef HAVE_LIBLZ4 @@ -60,7 +61,7 @@ You can contact the author at : ** By default, xxHash library provides endian-independent Hash values, based on little-endian convention. ** Results are therefore identical for little-endian and big-endian CPU. ** This comes at a performance cost for big-endian CPU, since some swapping is required to emulate little-endian format. -** Should endian-independance be of no importance for your application, you may set the #define below to 1. +** Should endian-independence be of no importance for your application, you may set the #define below to 1. ** It will improve speed for Big-endian CPU. ** This option has no impact on Little_Endian CPU. */ diff --git a/contrib/libarchive/tar/test/test_option_uid_uname.c b/contrib/libarchive/tar/test/test_option_uid_uname.c index 0a8a9bb..80c0619 100644 --- a/contrib/libarchive/tar/test/test_option_uid_uname.c +++ b/contrib/libarchive/tar/test/test_option_uid_uname.c @@ -45,25 +45,25 @@ DEFINE_TEST(test_option_uid_uname) /* Again with both --uid and --uname */ failure("Error invoking %s c", testprog); assertEqualInt(0, - systemf("%s cf archive2 --uid=17 --uname=foofoofoo --format=ustar file >stdout2.txt 2>stderr2.txt", + systemf("%s cf archive2 --uid=65123 --uname=foofoofoo --format=ustar file >stdout2.txt 2>stderr2.txt", testprog)); assertEmptyFile("stdout2.txt"); assertEmptyFile("stderr2.txt"); data = slurpfile(&s, "archive2"); /* Should force uid and uname fields in ustar header. */ - assertEqualMem(data + 108, "000021 \0", 8); + assertEqualMem(data + 108, "177143 \0", 8); assertEqualMem(data + 265, "foofoofoo\0", 10); free(data); /* Again with just --uid */ failure("Error invoking %s c", testprog); assertEqualInt(0, - systemf("%s cf archive3 --uid=17 --format=ustar file >stdout3.txt 2>stderr3.txt", + systemf("%s cf archive3 --uid=65123 --format=ustar file >stdout3.txt 2>stderr3.txt", testprog)); assertEmptyFile("stdout3.txt"); assertEmptyFile("stderr3.txt"); data = slurpfile(&s, "archive3"); - assertEqualMem(data + 108, "000021 \0", 8); + assertEqualMem(data + 108, "177143 \0", 8); /* Uname field in ustar header should be empty. */ assertEqualMem(data + 265, "\0", 1); free(data); diff --git a/contrib/libarchive/tar/util.c b/contrib/libarchive/tar/util.c index f845600..84dc53f 100644 --- a/contrib/libarchive/tar/util.c +++ b/contrib/libarchive/tar/util.c @@ -140,6 +140,7 @@ safe_fprintf(FILE *f, const char *fmt, ...) } else { /* Leave fmtbuff pointing to the truncated * string in fmtbuff_stack. */ + fmtbuff = fmtbuff_stack; length = sizeof(fmtbuff_stack) - 1; break; } diff --git a/lib/libarchive/config_freebsd.h b/lib/libarchive/config_freebsd.h index c82c8cc..24e2d75 100644 --- a/lib/libarchive/config_freebsd.h +++ b/lib/libarchive/config_freebsd.h @@ -39,6 +39,7 @@ #define HAVE_ACL_SET_FILE 1 #define HAVE_ACL_SET_LINK_NP 1 #define HAVE_ACL_USER 1 +#define HAVE_ACL_TYPE_NFS4 1 #define HAVE_ARC4RANDOM_BUF 1 #define HAVE_EXTATTR_GET_FILE 1 #define HAVE_EXTATTR_LIST_FILE 1 diff --git a/lib/libarchive/tests/Makefile b/lib/libarchive/tests/Makefile index 58c642e..ec17eee 100644 --- a/lib/libarchive/tests/Makefile +++ b/lib/libarchive/tests/Makefile @@ -21,11 +21,12 @@ CFLAGS+= -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1 .PATH: ${LIBARCHIVEDIR}/libarchive/test TESTS_SRCS= \ - test_acl_freebsd_nfs4.c \ - test_acl_freebsd_posix1e.c \ test_acl_nfs4.c \ test_acl_pax.c \ + test_acl_platform_nfs4.c \ + test_acl_platform_posix1e.c \ test_acl_posix1e.c \ + test_acl_text.c \ test_archive_api_feature.c \ test_archive_clear_error.c \ test_archive_cmdline.c \ @@ -74,7 +75,7 @@ TESTS_SRCS= \ test_compat_plexus_archiver_tar.c \ test_compat_solaris_tar_acl.c \ test_compat_solaris_pax_sparse.c \ - test_compat_star_acl_posix1e.c \ + test_compat_star_acl.c \ test_compat_tar_hardlink.c \ test_compat_uudecode.c \ test_compat_uudecode_large.c \ @@ -327,6 +328,7 @@ FILES+= test_compat_cpio_1.cpio.uu FILES+= test_compat_gtar_1.tar.uu FILES+= test_compat_gtar_2.tar.uu FILES+= test_compat_gzip_1.tgz.uu +FILES+= test_compat_gzip_2.tgz.uu FILES+= test_compat_lz4_1.tar.lz4.uu FILES+= test_compat_lz4_2.tar.lz4.uu FILES+= test_compat_lz4_3.tar.lz4.uu @@ -339,7 +341,6 @@ FILES+= test_compat_lz4_B6.tar.lz4.uu FILES+= test_compat_lz4_B6BD.tar.lz4.uu FILES+= test_compat_lz4_B7.tar.lz4.uu FILES+= test_compat_lz4_B7BD.tar.lz4.uu -FILES+= test_compat_gzip_2.tgz.uu FILES+= test_compat_lzip_1.tlz.uu FILES+= test_compat_lzip_2.tlz.uu FILES+= test_compat_lzma_1.tlz.uu @@ -486,7 +487,7 @@ FILES+= test_read_format_rar_compress_normal.rar.uu FILES+= test_read_format_rar_encryption_data.rar.uu FILES+= test_read_format_rar_encryption_header.rar.uu FILES+= test_read_format_rar_encryption_partially.rar.uu -FILES+= test_read_format_rar_invalid1.rar.uu +FILES+= test_read_format_rar_invalid1.rar.uu FILES+= test_read_format_rar_multi_lzss_blocks.rar.uu FILES+= test_read_format_rar_multivolume.part0001.rar.uu FILES+= test_read_format_rar_multivolume.part0002.rar.uu @@ -521,7 +522,7 @@ FILES+= test_read_format_zip_filename_koi8r.zip.uu FILES+= test_read_format_zip_filename_utf8_jp.zip.uu FILES+= test_read_format_zip_filename_utf8_ru.zip.uu FILES+= test_read_format_zip_filename_utf8_ru2.zip.uu -FILES+= test_read_format_zip_high_compression.zip.uu +FILES+= test_read_format_zip_high_compression.zip.uu FILES+= test_read_format_zip_jar.jar.uu FILES+= test_read_format_zip_length_at_end.zip.uu FILES+= test_read_format_zip_mac_metadata.zip.uu -- cgit v1.1 From a3e502df16f5e65c2c7a85cf7914ad1b1a6b7fa3 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 05:41:53 +0000 Subject: MFC r312452: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libpam/modules/Makefile.inc | 4 ++-- lib/libpam/modules/pam_passwdqc/Makefile | 2 +- lib/libpam/modules/pam_ssh/Makefile | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libpam/modules/Makefile.inc b/lib/libpam/modules/Makefile.inc index 8ff6ca6..f11c4ca 100644 --- a/lib/libpam/modules/Makefile.inc +++ b/lib/libpam/modules/Makefile.inc @@ -1,11 +1,11 @@ # $FreeBSD$ -PAMDIR= ${.CURDIR}/../../../../contrib/openpam +PAMDIR= ${SRCTOP}/contrib/openpam NO_INSTALLLIB= NO_PROFILE= -CFLAGS+= -I${PAMDIR}/include -I${.CURDIR}/../../libpam +CFLAGS+= -I${PAMDIR}/include -I${SRCTOP}/lib/libpam # This is nasty. # For the static case, libpam.a depends on the modules. diff --git a/lib/libpam/modules/pam_passwdqc/Makefile b/lib/libpam/modules/pam_passwdqc/Makefile index c9cc30e..97bffeb 100644 --- a/lib/libpam/modules/pam_passwdqc/Makefile +++ b/lib/libpam/modules/pam_passwdqc/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -SRCDIR= ${.CURDIR}/../../../../contrib/pam_modules/pam_passwdqc +SRCDIR= ${SRCTOP}/contrib/pam_modules/pam_passwdqc .PATH: ${SRCDIR} LIB= pam_passwdqc diff --git a/lib/libpam/modules/pam_ssh/Makefile b/lib/libpam/modules/pam_ssh/Makefile index 56f3781..8cb4cb9 100644 --- a/lib/libpam/modules/pam_ssh/Makefile +++ b/lib/libpam/modules/pam_ssh/Makefile @@ -1,7 +1,7 @@ # PAM module for SSH # $FreeBSD$ -SSHDIR= ${.CURDIR}/../../../../crypto/openssh +SSHDIR= ${SRCTOP}/crypto/openssh LIB= pam_ssh MAN= pam_ssh.8 -- cgit v1.1 From de3c8a8393e57cee9c79557bf110f789e3e1d2a7 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 05:43:34 +0000 Subject: MFC r312453: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libpam/libpam/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libpam/libpam/Makefile b/lib/libpam/libpam/Makefile index cfbe480..8f11ac2 100644 --- a/lib/libpam/libpam/Makefile +++ b/lib/libpam/libpam/Makefile @@ -35,7 +35,7 @@ # # $FreeBSD$ -OPENPAM= ${.CURDIR}/../../../contrib/openpam +OPENPAM= ${SRCTOP}/contrib/openpam .PATH: ${OPENPAM}/include ${OPENPAM}/lib/libpam ${OPENPAM}/doc/man LIB= pam -- cgit v1.1 From 5c39ef384e44dda7be5ef1710644f959ed3416ad Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 05:45:00 +0000 Subject: MFC r312454: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libalias/libalias/Makefile | 2 +- lib/libalias/modules/Makefile | 2 +- lib/libalias/modules/Makefile.inc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libalias/libalias/Makefile b/lib/libalias/libalias/Makefile index 00b4ed8..c192bc5 100644 --- a/lib/libalias/libalias/Makefile +++ b/lib/libalias/libalias/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../../sys/netinet/libalias +.PATH: ${SRCTOP}/sys/netinet/libalias LIB= alias SHLIBDIR?= /lib diff --git a/lib/libalias/modules/Makefile b/lib/libalias/modules/Makefile index dc66ad2..24333ea6 100644 --- a/lib/libalias/modules/Makefile +++ b/lib/libalias/modules/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include "${.CURDIR}/../../../sys/modules/libalias/modules/modules.inc" +.include "${SRCTOP}/sys/modules/libalias/modules/modules.inc" SUBDIR= ${MODULES} diff --git a/lib/libalias/modules/Makefile.inc b/lib/libalias/modules/Makefile.inc index 23df02d..730f374 100644 --- a/lib/libalias/modules/Makefile.inc +++ b/lib/libalias/modules/Makefile.inc @@ -1,6 +1,6 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../../../sys/netinet/libalias +.PATH: ${SRCTOP}/sys/netinet/libalias SHLIBDIR?= /lib LIB?= alias_${NAME} -- cgit v1.1 From 5174a5fe9de3683d0b43dae55acf3d76209c496d Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 05:47:56 +0000 Subject: MFC r312455: Use SRCTOP-relative paths and .CURDIR with :H instead of ".." specified paths This implifies pathing in make/displayed output --- lib/csu/amd64/Makefile | 6 +++--- lib/csu/arm/Makefile | 6 +++--- lib/csu/i386-elf/Makefile | 6 +++--- lib/csu/mips/Makefile | 6 +++--- lib/csu/powerpc/Makefile | 6 +++--- lib/csu/powerpc64/Makefile | 6 +++--- lib/csu/sparc64/Makefile | 5 +++-- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/csu/amd64/Makefile b/lib/csu/amd64/Makefile index 80d14a7..7341aec 100644 --- a/lib/csu/amd64/Makefile +++ b/lib/csu/amd64/Makefile @@ -1,12 +1,12 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../common +.PATH: ${.CURDIR:H}/common SRCS= crt1.c crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o -CFLAGS+= -I${.CURDIR}/../common \ - -I${.CURDIR}/../../libc/include +CFLAGS+= -I${.CURDIR:H}/common \ + -I${SRCTOP}/lib/libc/include CFLAGS+= -fno-omit-frame-pointer all: ${OBJS} diff --git a/lib/csu/arm/Makefile b/lib/csu/arm/Makefile index bf4c7b1..ca21fdb 100644 --- a/lib/csu/arm/Makefile +++ b/lib/csu/arm/Makefile @@ -1,12 +1,12 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../common +.PATH: ${.CURDIR:H}/common SRCS= crt1.c crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o -CFLAGS+= -I${.CURDIR}/../common \ - -I${.CURDIR}/../../libc/include +CFLAGS+= -I${.CURDIR:H}/common \ + -I${SRCTOP}/lib/libc/include all: ${OBJS} diff --git a/lib/csu/i386-elf/Makefile b/lib/csu/i386-elf/Makefile index f26db15..39d1a67 100644 --- a/lib/csu/i386-elf/Makefile +++ b/lib/csu/i386-elf/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../common +.PATH: ${.CURDIR:H}/common SRCS= crti.S crtn.S FILES= ${SRCS:N*.h:R:S/$/.o/g} gcrt1.o crt1.o Scrt1.o @@ -8,8 +8,8 @@ FILESOWN= ${LIBOWN} FILESGRP= ${LIBGRP} FILESMODE= ${LIBMODE} FILESDIR= ${LIBDIR} -CFLAGS+= -I${.CURDIR}/../common \ - -I${.CURDIR}/../../libc/include +CFLAGS+= -I${.CURDIR:H}/common \ + -I${SRCTOP}/libc/include CLEANFILES= ${FILES} crt1_c.o crt1_s.o gcrt1_c.o Scrt1_c.o CLEANFILES+= crt1_c.s gcrt1_c.s Scrt1_c.s diff --git a/lib/csu/mips/Makefile b/lib/csu/mips/Makefile index bf4c7b1..ca21fdb 100644 --- a/lib/csu/mips/Makefile +++ b/lib/csu/mips/Makefile @@ -1,12 +1,12 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../common +.PATH: ${.CURDIR:H}/common SRCS= crt1.c crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o -CFLAGS+= -I${.CURDIR}/../common \ - -I${.CURDIR}/../../libc/include +CFLAGS+= -I${.CURDIR:H}/common \ + -I${SRCTOP}/lib/libc/include all: ${OBJS} diff --git a/lib/csu/powerpc/Makefile b/lib/csu/powerpc/Makefile index bf4c7b1..ca21fdb 100644 --- a/lib/csu/powerpc/Makefile +++ b/lib/csu/powerpc/Makefile @@ -1,12 +1,12 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../common +.PATH: ${.CURDIR:H}/common SRCS= crt1.c crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o -CFLAGS+= -I${.CURDIR}/../common \ - -I${.CURDIR}/../../libc/include +CFLAGS+= -I${.CURDIR:H}/common \ + -I${SRCTOP}/lib/libc/include all: ${OBJS} diff --git a/lib/csu/powerpc64/Makefile b/lib/csu/powerpc64/Makefile index 123391e..b579db0 100644 --- a/lib/csu/powerpc64/Makefile +++ b/lib/csu/powerpc64/Makefile @@ -1,12 +1,12 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../common +.PATH: ${.CURDIR:H}/common SRCS= crt1.c crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o -CFLAGS+= -I${.CURDIR}/../common \ - -I${.CURDIR}/../../libc/include \ +CFLAGS+= -I${.CURDIR:H}/common \ + -I${SRCTOP}/lib/libc/include \ -mlongcall all: ${OBJS} diff --git a/lib/csu/sparc64/Makefile b/lib/csu/sparc64/Makefile index 7f8dd7a..6561997 100644 --- a/lib/csu/sparc64/Makefile +++ b/lib/csu/sparc64/Makefile @@ -1,11 +1,12 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../common +.PATH: ${.CURDIR:H}/common SRCS= crt1.c crti.S crtn.S OBJS= ${SRCS:N*.h:R:S/$/.o/g} OBJS+= Scrt1.o gcrt1.o -CFLAGS+= -I${.CURDIR}/../common -I${.CURDIR}/../../libc/include +CFLAGS+= -I${.CURDIR:H}/common \ + -I${SRCTOP}/lib/libc/include all: ${OBJS} -- cgit v1.1 From fbee5714f53d1a35972210733c8af3b6006ffba7 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 05:52:13 +0000 Subject: MFC r312456: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libarchive/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libarchive/Makefile b/lib/libarchive/Makefile index ffb2e97..2cf1633 100644 --- a/lib/libarchive/Makefile +++ b/lib/libarchive/Makefile @@ -1,7 +1,7 @@ # $FreeBSD$ .include -LIBARCHIVEDIR= ${.CURDIR}/../../contrib/libarchive +LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive LIB= archive DPADD= ${LIBZ} ${LIBBZ2} ${LIBLZMA} ${LIBPTHREAD} ${LIBBSDXML} -- cgit v1.1 From 9ff7b15b41c32715f5f1e71668bca8633ab637a2 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 05:53:13 +0000 Subject: MFC r312457: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libauditd/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libauditd/Makefile b/lib/libauditd/Makefile index cee1850..0c93cc6 100644 --- a/lib/libauditd/Makefile +++ b/lib/libauditd/Makefile @@ -2,7 +2,7 @@ # $FreeBSD$ # -OPENBSMDIR= ${.CURDIR}/../../contrib/openbsm +OPENBSMDIR= ${SRCTOP}/contrib/openbsm LIBAUDITDDIR= ${OPENBSMDIR}/libauditd LIBBSMDIR= ${OPENBSMDIR}/libbsm -- cgit v1.1 From b5d4edd3b68f19f24033dac87be8c50dddf7a908 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 05:55:25 +0000 Subject: MFC r312458: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libbegemot/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libbegemot/Makefile b/lib/libbegemot/Makefile index 27baf56..0f917c6 100644 --- a/lib/libbegemot/Makefile +++ b/lib/libbegemot/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -LIBBEGEMOT_DIR=${.CURDIR}/../../contrib/libbegemot +LIBBEGEMOT_DIR=${SRCTOP}/contrib/libbegemot .PATH: ${LIBBEGEMOT_DIR} -- cgit v1.1 From 5e8ae52006eaf266709367c4ce0bf287c95c29de Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 05:56:48 +0000 Subject: MFC r312459: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libblocksruntime/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libblocksruntime/Makefile b/lib/libblocksruntime/Makefile index 01a78fe..3dee852 100644 --- a/lib/libblocksruntime/Makefile +++ b/lib/libblocksruntime/Makefile @@ -5,7 +5,7 @@ SHLIB_MAJOR=0 CFLAGS+=-I${.CURDIR} WARNS?= 2 -.PATH: ${.CURDIR}/../../contrib/compiler-rt/BlocksRuntime +.PATH: ${SRCTOP}/contrib/compiler-rt/BlocksRuntime INCS= Block.h Block_private.h SRCS= data.c runtime.c -- cgit v1.1 From d18ac4f0e545cb1379fa972f5a8c9b2161e5a31f Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 05:57:35 +0000 Subject: MFC r312460: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libbluetooth/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libbluetooth/Makefile b/lib/libbluetooth/Makefile index 7e21892..7a2e134 100644 --- a/lib/libbluetooth/Makefile +++ b/lib/libbluetooth/Makefile @@ -5,7 +5,7 @@ LIB= bluetooth MAN= bluetooth.3 WARNS?= 2 -CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../../sys +CFLAGS+= -I${.CURDIR} -I${SRCTOP}/sys SHLIB_MAJOR= 4 -- cgit v1.1 From ae7938c73edbd8c85b620f16f82d05a09d45f5ad Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 05:58:20 +0000 Subject: MFC r312461: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libbsm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libbsm/Makefile b/lib/libbsm/Makefile index 2e0dbe1..90fbc27 100644 --- a/lib/libbsm/Makefile +++ b/lib/libbsm/Makefile @@ -2,7 +2,7 @@ # $FreeBSD$ # -OPENBSMDIR= ${.CURDIR}/../../contrib/openbsm +OPENBSMDIR= ${SRCTOP}/contrib/openbsm LIBBSMDIR= ${OPENBSMDIR}/libbsm LIB= bsm -- cgit v1.1 From d05175b168ef640fdcb0765160ed74197c1ba37c Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 05:59:39 +0000 Subject: MFC r312462: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libbsnmp/libbsnmp/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libbsnmp/libbsnmp/Makefile b/lib/libbsnmp/libbsnmp/Makefile index a756f90..708e3ee 100644 --- a/lib/libbsnmp/libbsnmp/Makefile +++ b/lib/libbsnmp/libbsnmp/Makefile @@ -4,7 +4,7 @@ .include -CONTRIB= ${.CURDIR}/../../../contrib/bsnmp/lib +CONTRIB= ${SRCTOP}/contrib/bsnmp/lib .PATH: ${CONTRIB} LIB= bsnmp -- cgit v1.1 From f7558dc7498e5054ab7bbea6b2c342c5e8ed4ed3 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:17:10 +0000 Subject: Unbreak the build after ^/stable/10@r313571 Update FILES per tests removed in beforementioned commit, which were accidentally overlooked, no doubt due to conflicts after base packaging work. This is a direct commit to ^/stable/10 Reported by: Jenkins (FreeBSD-stable-10-amd64-build job) --- lib/libarchive/tests/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libarchive/tests/Makefile b/lib/libarchive/tests/Makefile index ec17eee..eed7b97 100644 --- a/lib/libarchive/tests/Makefile +++ b/lib/libarchive/tests/Makefile @@ -320,7 +320,8 @@ list.h: ${TESTS_SRCS} Makefile CLEANFILES+= list.h list.h.tmp FILES+= README -FILES+= test_acl_pax.tar.uu +FILES+= test_acl_pax_posix1e.tar.uu +FILES+= test_acl_pax_nfs4.tar.uu FILES+= test_archive_string_conversion.txt.Z.uu FILES+= test_compat_bzip2_1.tbz.uu FILES+= test_compat_bzip2_2.tbz.uu @@ -357,6 +358,7 @@ FILES+= test_compat_plexus_archiver_tar.tar.uu FILES+= test_compat_solaris_pax_sparse_1.pax.Z.uu FILES+= test_compat_solaris_pax_sparse_2.pax.Z.uu FILES+= test_compat_solaris_tar_acl.tar.uu +FILES+= test_compat_star_acl_nfs4.tar.uu FILES+= test_compat_star_acl_posix1e.tar.uu FILES+= test_compat_tar_hardlink_1.tar.uu FILES+= test_compat_uudecode_large.tar.Z.uu @@ -548,6 +550,7 @@ FILES+= test_read_large_splitted_rar_ab.uu FILES+= test_read_large_splitted_rar_ac.uu FILES+= test_read_large_splitted_rar_ad.uu FILES+= test_read_large_splitted_rar_ae.uu +FILES+= test_read_pax_schily_xattr.tar.uu FILES+= test_read_splitted_rar_aa.uu FILES+= test_read_splitted_rar_ab.uu FILES+= test_read_splitted_rar_ac.uu -- cgit v1.1 From 54b7fbc0525e5bca15cb36181e82168ea907bcff Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:19:25 +0000 Subject: MFC r312463: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libbz2/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libbz2/Makefile b/lib/libbz2/Makefile index b505927..2521009 100644 --- a/lib/libbz2/Makefile +++ b/lib/libbz2/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -BZ2DIR= ${.CURDIR}/../../contrib/bzip2 +BZ2DIR= ${SRCTOP}/contrib/bzip2 .PATH: ${BZ2DIR} LIB= bz2 -- cgit v1.1 From 547c246df9b5a794c81f5f061dc7ad478584787a Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:21:38 +0000 Subject: MFC r312464: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libc++/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile index 8c804a3..48cfe27 100644 --- a/lib/libc++/Makefile +++ b/lib/libc++/Makefile @@ -2,9 +2,9 @@ .include -LIBCXXRTDIR= ${.CURDIR}/../../contrib/libcxxrt -HDRDIR= ${.CURDIR}/../../contrib/libc++/include -SRCDIR= ${.CURDIR}/../../contrib/libc++/src +LIBCXXRTDIR= ${SRCTOP}/contrib/libcxxrt +HDRDIR= ${SRCTOP}/contrib/libc++/include +SRCDIR= ${SRCTOP}/contrib/libc++/src CXXINCLUDEDIR= ${INCLUDEDIR}/c++/v${SHLIB_MAJOR} .PATH: ${SRCDIR} -- cgit v1.1 From 6dcc2527e066ad692e628cf5decfa5f5446b06f1 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:22:29 +0000 Subject: MFC r312465: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libcam/Makefile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/libcam/Makefile b/lib/libcam/Makefile index 9a21dde..af28912 100644 --- a/lib/libcam/Makefile +++ b/lib/libcam/Makefile @@ -36,11 +36,10 @@ MLINKS+= cam.3 cam_open_device.3 \ cam_cdbparse.3 csio_encode_visit.3 \ cam_cdbparse.3 buff_encode_visit.3 -.PATH: ${.CURDIR}/../../sys/cam/scsi ${.CURDIR}/../../sys/cam/ata \ - ${.CURDIR}/../../sys/cam +.PATH: ${SRCTOP}/sys/cam/scsi ${SRCTOP}/sys/cam/ata \ + ${SRCTOP}/sys/cam -SDIR= ${.CURDIR}/../../sys -CFLAGS+= -I${.CURDIR} -I${SDIR} +CFLAGS+= -I${.CURDIR} -I${SRCTOP}/sys SHLIB_MAJOR= 6 -- cgit v1.1 From 51afc9a345bf4460a36bc44f58255ad29e4498ab Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:23:07 +0000 Subject: MFC r312466: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libc_nonshared/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libc_nonshared/Makefile b/lib/libc_nonshared/Makefile index 4c2a945..d32f365 100644 --- a/lib/libc_nonshared/Makefile +++ b/lib/libc_nonshared/Makefile @@ -6,7 +6,7 @@ # bsd.lib.mk doesn't have an easy way to express that. NO_PROFILE?= .include -NO_PIC= +NO_PIC= # -fpic on some platforms, -fPIC on others. CFLAGS+=${PICFLAG} -DPIC -fvisibility=hidden @@ -18,9 +18,9 @@ LIBC_NONSHARED_SRCS= SRCS= __stub.c .if ${MK_ICONV} == "yes" -.PATH: ${.CURDIR}/../libc/iconv +.PATH: ${SRCTOP}/lib/libc/iconv .include "Makefile.iconv" -CFLAGS+=-I${.CURDIR}/../libc/iconv +CFLAGS+=-I${SRCTOP}/lib/libc/iconv .endif SRCS+= ${LIBC_NONSHARED_SRCS} -- cgit v1.1 From b4ae035355742f3d194d46ec22685074543eb601 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:25:47 +0000 Subject: MFC r312467: Use SRCTOP-relative paths and .CURDIR with :H instead of ".." specified paths This implifies pathing in make/displayed output --- lib/ncurses/config.mk | 12 ++++++------ lib/ncurses/form/Makefile | 2 +- lib/ncurses/formw/Makefile | 2 +- lib/ncurses/menu/Makefile | 2 +- lib/ncurses/menuw/Makefile | 2 +- lib/ncurses/ncurses/Makefile | 2 +- lib/ncurses/ncursesw/Makefile | 4 ++-- lib/ncurses/panel/Makefile | 2 +- lib/ncurses/panelw/Makefile | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/ncurses/config.mk b/lib/ncurses/config.mk index d01e17a..d15be86 100644 --- a/lib/ncurses/config.mk +++ b/lib/ncurses/config.mk @@ -2,25 +2,25 @@ # This Makefile is shared by libncurses, libform, libmenu, libpanel. -NCURSES_DIR= ${.CURDIR}/../../../contrib/ncurses +NCURSES_DIR= ${SRCTOP}/contrib/ncurses .if defined(ENABLE_WIDEC) LIB_SUFFIX= w CFLAGS+= -D_XOPEN_SOURCE_EXTENDED -DENABLE_WIDEC -NCURSES_CFG_H= ${.CURDIR}/../ncurses/ncurses_cfg.h +NCURSES_CFG_H= ${.CURDIR:H}/ncurses/ncurses_cfg.h .else LIB_SUFFIX= NCURSES_CFG_H= ${.CURDIR}/ncurses_cfg.h .endif CFLAGS+= -I. -.if exists(${.OBJDIR}/../ncurses${LIB_SUFFIX}) -CFLAGS+= -I${.OBJDIR}/../ncurses${LIB_SUFFIX} +.if exists(${.OBJDIR:H}/ncurses${LIB_SUFFIX}) +CFLAGS+= -I${.OBJDIR:H}/ncurses${LIB_SUFFIX} .endif -CFLAGS+= -I${.CURDIR}/../ncurses${LIB_SUFFIX} +CFLAGS+= -I${.CURDIR:H}/ncurses${LIB_SUFFIX} # for ${NCURSES_CFG_H} -CFLAGS+= -I${.CURDIR}/../ncurses +CFLAGS+= -I${.CURDIR:H}/ncurses CFLAGS+= -I${NCURSES_DIR}/include CFLAGS+= -I${NCURSES_DIR}/ncurses diff --git a/lib/ncurses/form/Makefile b/lib/ncurses/form/Makefile index b79dc41..5af3d2a 100644 --- a/lib/ncurses/form/Makefile +++ b/lib/ncurses/form/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include "${.CURDIR}/../config.mk" +.include "${.CURDIR:H}/config.mk" SRCDIR= ${NCURSES_DIR}/form diff --git a/lib/ncurses/formw/Makefile b/lib/ncurses/formw/Makefile index 5488503..3ec7637 100644 --- a/lib/ncurses/formw/Makefile +++ b/lib/ncurses/formw/Makefile @@ -2,4 +2,4 @@ ENABLE_WIDEC= -.include "${.CURDIR}/../form/Makefile" +.include "${.CURDIR:H}/form/Makefile" diff --git a/lib/ncurses/menu/Makefile b/lib/ncurses/menu/Makefile index 3aac081..fb5afd2 100644 --- a/lib/ncurses/menu/Makefile +++ b/lib/ncurses/menu/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include "${.CURDIR}/../config.mk" +.include "${.CURDIR:H}/config.mk" SRCDIR= ${NCURSES_DIR}/menu diff --git a/lib/ncurses/menuw/Makefile b/lib/ncurses/menuw/Makefile index d5a100f..d6df563 100644 --- a/lib/ncurses/menuw/Makefile +++ b/lib/ncurses/menuw/Makefile @@ -2,4 +2,4 @@ ENABLE_WIDEC= -.include "${.CURDIR}/../menu/Makefile" +.include "${.CURDIR:H}/menu/Makefile" diff --git a/lib/ncurses/ncurses/Makefile b/lib/ncurses/ncurses/Makefile index ee4d89e..afd0f40 100644 --- a/lib/ncurses/ncurses/Makefile +++ b/lib/ncurses/ncurses/Makefile @@ -8,7 +8,7 @@ NO_MAN= .include -.include "${.CURDIR}/../config.mk" +.include "${.CURDIR:H}/config.mk" LIB= ncurses${LIB_SUFFIX} SHLIB_MAJOR= 8 diff --git a/lib/ncurses/ncursesw/Makefile b/lib/ncurses/ncursesw/Makefile index 277c90b..5f6040e 100644 --- a/lib/ncurses/ncursesw/Makefile +++ b/lib/ncurses/ncursesw/Makefile @@ -2,6 +2,6 @@ ENABLE_WIDEC= -.PATH: ${.CURDIR}/../ncurses +.PATH: ${.CURDIR:H}/ncurses -.include "${.CURDIR}/../ncurses/Makefile" +.include "${.CURDIR:H}/ncurses/Makefile" diff --git a/lib/ncurses/panel/Makefile b/lib/ncurses/panel/Makefile index 7929aed..881f31a 100644 --- a/lib/ncurses/panel/Makefile +++ b/lib/ncurses/panel/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include "${.CURDIR}/../config.mk" +.include "${.CURDIR:H}/config.mk" SRCDIR= ${NCURSES_DIR}/panel diff --git a/lib/ncurses/panelw/Makefile b/lib/ncurses/panelw/Makefile index 7642e34..2585738 100644 --- a/lib/ncurses/panelw/Makefile +++ b/lib/ncurses/panelw/Makefile @@ -2,4 +2,4 @@ ENABLE_WIDEC= -.include "${.CURDIR}/../panel/Makefile" +.include "${.CURDIR:H}/panel/Makefile" -- cgit v1.1 From 868f996837a7432d010683c91c937fddd020e19c Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:27:42 +0000 Subject: MFC r312468: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libthread_db/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libthread_db/Makefile b/lib/libthread_db/Makefile index b612f4f..b5e18747 100644 --- a/lib/libthread_db/Makefile +++ b/lib/libthread_db/Makefile @@ -14,7 +14,7 @@ CFLAGS+=-I. -I${.CURDIR} SYM_MAPS+=${.CURDIR}/Symbol.map SYMBOL_MAPS=${SYM_MAPS} -VERSION_DEF=${.CURDIR}/../libc/Versions.def +VERSION_DEF=${SRCTOP}/lib/libc/Versions.def # Unfortunately, clang gives an incorrect warning about alignment in # arch/i386/libpthread_md.c, so turn that off for now. -- cgit v1.1 From 111661de482eeada4faea3eb715939145a3674fe Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:30:25 +0000 Subject: MFC r312469: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libypclnt/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libypclnt/Makefile b/lib/libypclnt/Makefile index 2e302f1..636c9b6 100644 --- a/lib/libypclnt/Makefile +++ b/lib/libypclnt/Makefile @@ -23,9 +23,9 @@ GENSRCS=yp.h \ yppasswd_private_xdr.c RPCGEN= RPCGEN_CPP=${CPP:Q} rpcgen -C -RPCSRC= ${.CURDIR}/../../include/rpcsvc/yp.x -RPCSRC_PW= ${.CURDIR}/../../include/rpcsvc/yppasswd.x -RPCSRC_PRIV= ${.CURDIR}/../../usr.sbin/rpc.yppasswdd/yppasswd_private.x +RPCSRC= ${SRCTOP}/include/rpcsvc/yp.x +RPCSRC_PW= ${SRCTOP}/include/rpcsvc/yppasswd.x +RPCSRC_PRIV= ${SRCTOP}/usr.sbin/rpc.yppasswdd/yppasswd_private.x yp.h: ${RPCSRC} ${RPCGEN} -h -o ${.TARGET} ${RPCSRC} -- cgit v1.1 From 6be22aee9df34905826b199ac88bb040eb1e8439 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:31:26 +0000 Subject: MFC r312470: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libutil/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile index 4e10729..11ebb3f 100644 --- a/lib/libutil/Makefile +++ b/lib/libutil/Makefile @@ -24,7 +24,7 @@ CFLAGS+= -DLIBC_SCCS CFLAGS+= -DINET6 .endif -CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../libc/gen/ +CFLAGS+= -I${.CURDIR} -I${SRCTOP}/lib/libc/gen/ MAN+= expand_number.3 flopen.3 fparseln.3 hexdump.3 \ humanize_number.3 kinfo_getallproc.3 kinfo_getfile.3 \ -- cgit v1.1 From 337a7baed903a3007f7f8b4a42989078ddf3260a Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:32:05 +0000 Subject: MFC r312471: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libulog/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libulog/Makefile b/lib/libulog/Makefile index 074d9db..b5de8f0 100644 --- a/lib/libulog/Makefile +++ b/lib/libulog/Makefile @@ -22,7 +22,7 @@ MLINKS+=ulog_login.3 ulog_login_pseudo.3 \ DPADD= ${LIBMD} LDADD= -lmd -VERSION_DEF= ${.CURDIR}/../libc/Versions.def +VERSION_DEF= ${SRCTOP}/lib/libc/Versions.def SYMBOL_MAPS= ${.CURDIR}/Symbol.map .if ${MK_INSTALLLIB} != "no" -- cgit v1.1 From 938881744bd9d44192f0c11475e2246240a97e6c Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:32:48 +0000 Subject: MFC r312472: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libufs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libufs/Makefile b/lib/libufs/Makefile index 78832d8..c809241 100644 --- a/lib/libufs/Makefile +++ b/lib/libufs/Makefile @@ -17,7 +17,7 @@ MLINKS+= ufs_disk_close.3 ufs_disk_fillout.3 MLINKS+= ufs_disk_close.3 ufs_disk_fillout_blank.3 MLINKS+= ufs_disk_close.3 ufs_disk_write.3 -.PATH: ${.CURDIR}/../../sys/ufs/ffs +.PATH: ${SRCTOP}/sys/ufs/ffs WARNS?= 2 -- cgit v1.1 From c124588aa50a97b6421e589c0badd4ea7a311c81 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:33:46 +0000 Subject: MFC r312473: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libunbound/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libunbound/Makefile b/lib/libunbound/Makefile index 3c66181..e2471bf 100644 --- a/lib/libunbound/Makefile +++ b/lib/libunbound/Makefile @@ -1,8 +1,8 @@ # $FreeBSD$ # Vendor sources and generated files -LDNSDIR= ${.CURDIR}/../../contrib/ldns -UNBOUNDDIR= ${.CURDIR}/../../contrib/unbound +LDNSDIR= ${SRCTOP}/contrib/ldns +UNBOUNDDIR= ${SRCTOP}/contrib/unbound # Hold my beer and watch this .PATH: ${UNBOUNDDIR} ${UNBOUNDDIR}/compat ${UNBOUNDDIR}/dns64 ${UNBOUNDDIR}/iterator ${UNBOUNDDIR}/sldns ${UNBOUNDDIR}/libunbound ${UNBOUNDDIR}/services ${UNBOUNDDIR}/services/cache ${UNBOUNDDIR}/util ${UNBOUNDDIR}/util/data ${UNBOUNDDIR}/util/storage ${UNBOUNDDIR}/validator -- cgit v1.1 From 4e4248c6dbe8085ccce70a08c576e34cedb6b439 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:35:29 +0000 Subject: MFC r312474: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libthr/Makefile | 12 ++++++------ lib/libthr/support/Makefile.inc | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/libthr/Makefile b/lib/libthr/Makefile index 8b333dd..a7d2868 100644 --- a/lib/libthr/Makefile +++ b/lib/libthr/Makefile @@ -17,13 +17,13 @@ LIB=thr SHLIB_MAJOR= 3 WARNS?= 3 CFLAGS+=-DPTHREAD_KERNEL -CFLAGS+=-I${.CURDIR}/../libc/include -I${.CURDIR}/thread \ - -I${.CURDIR}/../../include +CFLAGS+=-I${SRCTOP}/lib/libc/include -I${.CURDIR}/thread \ + -I${SRCTOP}/include CFLAGS+=-I${.CURDIR}/arch/${MACHINE_CPUARCH}/include CFLAGS+=-I${.CURDIR}/sys -CFLAGS+=-I${.CURDIR}/../../libexec/rtld-elf -CFLAGS+=-I${.CURDIR}/../../libexec/rtld-elf/${MACHINE_CPUARCH} -CFLAGS+=-I${.CURDIR}/../libthread_db +CFLAGS+=-I${SRCTOP}/libexec/rtld-elf +CFLAGS+=-I${SRCTOP}/libexec/rtld-elf/${MACHINE_CPUARCH} +CFLAGS+=-I${SRCTOP}/lib/libthread_db CFLAGS+=-Winline .ifndef NO_THREAD_UNWIND_STACK @@ -33,7 +33,7 @@ CFLAGS+=-D_PTHREAD_FORCED_UNWIND LDFLAGS+=-Wl,-znodelete -VERSION_DEF=${.CURDIR}/../libc/Versions.def +VERSION_DEF=${SRCTOP}/lib/libc/Versions.def SYMBOL_MAPS=${.CURDIR}/pthread.map MAN= libthr.3 diff --git a/lib/libthr/support/Makefile.inc b/lib/libthr/support/Makefile.inc index 35a15f8..14b3131 100644 --- a/lib/libthr/support/Makefile.inc +++ b/lib/libthr/support/Makefile.inc @@ -1,15 +1,15 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/support ${.CURDIR}/../libc/gen ${.CURDIR}/../libc/string +.PATH: ${.CURDIR}/support ${SRCTOP}/lib/libc/gen ${SRCTOP}/lib/libc/string # libc must search machine_arch, then machine_cpuarch, but libthr has all its # code implemented in machine_cpuarch. Cope. -.if exists(${.CURDIR}/../libc/${MACHINE_ARCH}/sys) -.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/sys -CFLAGS+= -I${.CURDIR}/../libc/${MACHINE_ARCH} +.if exists(${SRCTOP}/lib/libc/${MACHINE_ARCH}/sys) +.PATH: ${SRCTOP}/lib/libc/${MACHINE_ARCH}/sys +CFLAGS+= -I${SRCTOP}/lib/libc/${MACHINE_ARCH} .else -.PATH: ${.CURDIR}/../libc/${MACHINE_CPUARCH}/sys -CFLAGS+= -I${.CURDIR}/../libc/${MACHINE_CPUARCH} +.PATH: ${SRCTOP}/lib/libc/${MACHINE_CPUARCH}/sys +CFLAGS+= -I${SRCTOP}/lib/libc/${MACHINE_CPUARCH} .endif SYSCALLS= thr_new -- cgit v1.1 From 07d65f669de070647faca244b997cc1daccfbec9 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:36:12 +0000 Subject: MFC r312475: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libtelnet/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libtelnet/Makefile b/lib/libtelnet/Makefile index 1cf52a0..bab5fa9 100644 --- a/lib/libtelnet/Makefile +++ b/lib/libtelnet/Makefile @@ -3,7 +3,7 @@ .include -TELNETDIR= ${.CURDIR}/../../contrib/telnet +TELNETDIR= ${SRCTOP}/contrib/telnet .PATH: ${TELNETDIR}/libtelnet LIB= telnet -- cgit v1.1 From 428cab406e0dfc3e798fe8e6f25987f601bfb871 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:37:24 +0000 Subject: MFC r312477: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libstdthreads/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libstdthreads/Makefile b/lib/libstdthreads/Makefile index 544eeb0..d2eed8a 100644 --- a/lib/libstdthreads/Makefile +++ b/lib/libstdthreads/Makefile @@ -35,7 +35,7 @@ MLINKS= thrd_create.3 call_once.3 \ DPADD= ${LIBPTHREAD} LDADD= -lpthread -VERSION_DEF= ${.CURDIR}/../libc/Versions.def +VERSION_DEF= ${SRCTOP}/lib/libc/Versions.def SYMBOL_MAPS= ${.CURDIR}/Symbol.map .include -- cgit v1.1 From 9624cc62c98b90ce79685a6d7430e95dced77a07 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:38:22 +0000 Subject: MFC r312479: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libsmutil/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libsmutil/Makefile b/lib/libsmutil/Makefile index b7e5a69..32f8a5d 100644 --- a/lib/libsmutil/Makefile +++ b/lib/libsmutil/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail +SENDMAIL_DIR=${SRCTOP}/contrib/sendmail .PATH: ${SENDMAIL_DIR}/libsmutil CFLAGS+=-I${SENDMAIL_DIR}/src -I${SENDMAIL_DIR}/include -I. -- cgit v1.1 From 53c3bcd6fe3558f6b07bd4cdbc8d09b6ec154b18 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:39:04 +0000 Subject: MFC r312480: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libsmb/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libsmb/Makefile b/lib/libsmb/Makefile index e464a8f..5644a83 100644 --- a/lib/libsmb/Makefile +++ b/lib/libsmb/Makefile @@ -2,7 +2,7 @@ .include -CONTRIBDIR= ${.CURDIR}/../../contrib/smbfs +CONTRIBDIR= ${SRCTOP}/contrib/smbfs .PATH: ${CONTRIBDIR}/lib/smb LIB= smb -- cgit v1.1 From 0addba1a44115fada07bf54642a0faa389c8be81 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:39:47 +0000 Subject: MFC r312481: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libsmdb/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libsmdb/Makefile b/lib/libsmdb/Makefile index 976282c..0116634 100644 --- a/lib/libsmdb/Makefile +++ b/lib/libsmdb/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail +SENDMAIL_DIR=${SRCTOP}/contrib/sendmail .PATH: ${SENDMAIL_DIR}/libsmdb CFLAGS+=-I${SENDMAIL_DIR}/src -I${SENDMAIL_DIR}/include -I. -- cgit v1.1 From 55182923d7c3d364e9cfdad32c332156cc0b1473 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:40:27 +0000 Subject: MFC r312482: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libsm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libsm/Makefile b/lib/libsm/Makefile index 012e033..6e9516e 100644 --- a/lib/libsm/Makefile +++ b/lib/libsm/Makefile @@ -2,7 +2,7 @@ .include -SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail +SENDMAIL_DIR=${SRCTOP}/contrib/sendmail .PATH: ${SENDMAIL_DIR}/libsm CFLAGS+=-I${SENDMAIL_DIR}/src -I${SENDMAIL_DIR}/include -I. -- cgit v1.1 From 370632322562c42ef19d70bc8fa26bbc85d4dcb5 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:41:07 +0000 Subject: MFC r312483: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libsbuf/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libsbuf/Makefile b/lib/libsbuf/Makefile index 98ceeb6..260ae81 100644 --- a/lib/libsbuf/Makefile +++ b/lib/libsbuf/Makefile @@ -9,6 +9,6 @@ SHLIB_MAJOR = 6 SYMBOL_MAPS= ${.CURDIR}/Symbol.map VERSION_DEF= ${.CURDIR}/Version.def -.PATH: ${.CURDIR}/../../sys/kern +.PATH: ${SRCTOP}/sys/kern .include -- cgit v1.1 From 41afbeb690188297177d2e296cfe6606be7982d4 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:42:56 +0000 Subject: MFC r312485: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/librpcsvc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librpcsvc/Makefile b/lib/librpcsvc/Makefile index 9c9e3ae..0bce2a8 100644 --- a/lib/librpcsvc/Makefile +++ b/lib/librpcsvc/Makefile @@ -3,7 +3,7 @@ .include -.PATH: ${.CURDIR}/../../include/rpcsvc +.PATH: ${SRCTOP}/include/rpcsvc LIB= rpcsvc -- cgit v1.1 From 7a9fa85f80243fcc703debb436c7302e6b60ddea Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:44:16 +0000 Subject: MFC r312486: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/librpcsec_gss/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librpcsec_gss/Makefile b/lib/librpcsec_gss/Makefile index cc14a7b..223b684 100644 --- a/lib/librpcsec_gss/Makefile +++ b/lib/librpcsec_gss/Makefile @@ -8,11 +8,11 @@ SRCS+= rpcsec_gss.c rpcsec_gss_prot.c rpcsec_gss_conf.c rpcsec_gss_misc.c \ DPADD+= ${LIBGSSAPI} LDADD+= -lgssapi -VERSION_DEF= ${.CURDIR}/../libc/Versions.def +VERSION_DEF= ${SRCTOP}/lib/libc/Versions.def SYMBOL_MAPS= ${.CURDIR}/Symbol.map -CFLAGS+= -I${.CURDIR}/../../include -CFLAGS+= -I${.CURDIR}/../../libc_rpc +CFLAGS+= -I${SRCTOP}/include +CFLAGS+= -I${SRCTOP}/lib/libc_rpc NO_PROFILE= MAN= rpcsec_gss.3 -- cgit v1.1 From 28a42a4bdfab8888ac489766d61b1fbf090208c8 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:46:16 +0000 Subject: MFC r312489: Use SRCTOP-relative paths and .CURDIR with :H instead of ".." specified paths This implifies pathing in make/displayed output --- lib/libprocstat/zfs/Makefile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/libprocstat/zfs/Makefile b/lib/libprocstat/zfs/Makefile index 9200f02..a58f298 100644 --- a/lib/libprocstat/zfs/Makefile +++ b/lib/libprocstat/zfs/Makefile @@ -1,21 +1,21 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/.. +.PATH: ${.CURDIR:H} SRCS= zfs.c OBJS= zfs.o WARNS?= 1 -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris -CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include -CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem -CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys -CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head -CFLAGS+= -I${.CURDIR}/.. +CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris +CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include +CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/lib/libumem +CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzpool/common +CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs +CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs +CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common +CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys +CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/head +CFLAGS+= -I${.CURDIR:H} CFLAGS+= -DNEED_SOLARIS_BOOLEAN all: ${OBJS} -- cgit v1.1 From ae1a2b54739e2588f2a71ac0793e1a1c91903563 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:47:07 +0000 Subject: MFC r312490: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libpcap/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libpcap/Makefile b/lib/libpcap/Makefile index e7401a85..d9d9b4fe 100644 --- a/lib/libpcap/Makefile +++ b/lib/libpcap/Makefile @@ -110,7 +110,7 @@ SHLIB_MAJOR= 8 # # Magic to grab sources out of src/contrib # -PCAP_DISTDIR?=${.CURDIR}/../../contrib/libpcap +PCAP_DISTDIR?=${SRCTOP}/contrib/libpcap CFLAGS+=-I${PCAP_DISTDIR} .PATH: ${PCAP_DISTDIR} .PATH: ${PCAP_DISTDIR}/bpf/net -- cgit v1.1 From 5eb51663f55e50382fd7dcd3ec27e7de85fa1d27 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:47:56 +0000 Subject: MFC r312491: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This implifies pathing in make/displayed output --- lib/libopie/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libopie/Makefile b/lib/libopie/Makefile index 647bfee..dd21192 100644 --- a/lib/libopie/Makefile +++ b/lib/libopie/Makefile @@ -2,7 +2,7 @@ # # $FreeBSD$ # -OPIE_DIST?= ${.CURDIR}/../../contrib/opie +OPIE_DIST?= ${SRCTOP}/contrib/opie DIST_DIR= ${OPIE_DIST}/${.CURDIR:T} SHLIB_MAJOR= 7 -- cgit v1.1 From a0737f1d6c506ad7eee325e462ef0e9d12951e4f Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:50:25 +0000 Subject: MFC r312493: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This simplifies pathing in make/displayed output --- lib/libngatm/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libngatm/Makefile b/lib/libngatm/Makefile index 85294b0..47dc716 100644 --- a/lib/libngatm/Makefile +++ b/lib/libngatm/Makefile @@ -7,8 +7,8 @@ SHLIB_MAJOR= 4 MAN= libngatm.3 uniaddr.3 unifunc.3 unimsg.3 unisap.3 unistruct.3 # source of the library lives in contrib -SDIR= ${.CURDIR}/../../sys -CTRB= ${.CURDIR}/../../contrib/ngatm +SDIR= ${SRCTOP}/sys +CTRB= ${SRCTOP}/contrib/ngatm LIBBASE= ${SDIR}/contrib/ngatm CFLAGS+= -I${LIBBASE} -I${.OBJDIR} -I${CTRB}/libngatm -- cgit v1.1 From 82c5731b4b1b14e49d27d311984b9af64a41d875 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:51:09 +0000 Subject: MFC r312494: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This simplifies pathing in make/displayed output --- lib/libmp/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libmp/Makefile b/lib/libmp/Makefile index 67f6edd..08a52f5 100644 --- a/lib/libmp/Makefile +++ b/lib/libmp/Makefile @@ -10,9 +10,9 @@ MAN= libmp.3 INCS= mp.h SRCS= mpasbn.c -CFLAGS+= -I${.CURDIR}/../../crypto +CFLAGS+= -I${SRCTOP}/crypto -VERSION_DEF= ${.CURDIR}/../libc/Versions.def +VERSION_DEF= ${SRCTOP}/lib/libc/Versions.def SYMBOL_MAPS= ${.CURDIR}/Symbol.map .if ${MK_TESTS} != "no" -- cgit v1.1 From 5e4dbe719f859c3067902f331e43edec0f352412 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:51:53 +0000 Subject: MFC r312495: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This simplifies pathing in make/displayed output --- lib/libmilter/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libmilter/Makefile b/lib/libmilter/Makefile index 0e625d0..00c0548 100644 --- a/lib/libmilter/Makefile +++ b/lib/libmilter/Makefile @@ -2,7 +2,7 @@ .include -SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail +SENDMAIL_DIR=${SRCTOP}/contrib/sendmail .PATH: ${SENDMAIL_DIR}/libmilter ${SENDMAIL_DIR}/libsm CFLAGS+=-I${SENDMAIL_DIR}/src -I${SENDMAIL_DIR}/include -I. -- cgit v1.1 From 4ae51ed9e3f40efc3323f01d77a3c6190a5caf47 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:54:42 +0000 Subject: MFC r312497: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This simplifies pathing in make/displayed output --- lib/libmagic/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libmagic/Makefile b/lib/libmagic/Makefile index 935a0ef..08ad9b4 100644 --- a/lib/libmagic/Makefile +++ b/lib/libmagic/Makefile @@ -1,7 +1,7 @@ # $FreeBSD$ # Copyright (c) David E. O'Brien, 2000-2004, 2006, 2009 -CONTRDIR= ${.CURDIR}/../../contrib/file +CONTRDIR= ${SRCTOP}/contrib/file .PATH: ${CONTRDIR}/src .PATH: ${CONTRDIR}/doc -- cgit v1.1 From a06cd8965b7189fd9c0f534053be78bb30ce3e7c Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:55:35 +0000 Subject: MFC r312498: Use SRCTOP-relative paths and .CURDIR with :H instead of ".." specified paths This simplifies pathing in make/displayed output --- lib/liblzma/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/liblzma/Makefile b/lib/liblzma/Makefile index c78933a..24ed42c 100644 --- a/lib/liblzma/Makefile +++ b/lib/liblzma/Makefile @@ -1,9 +1,9 @@ # $FreeBSD$ LIB= lzma -LZMADIR= ${.CURDIR}/../../contrib/xz/src/liblzma +LZMADIR= ${SRCTOP}/contrib/xz/src/liblzma -.PATH: ${LZMADIR}/../common +.PATH: ${LZMADIR:H}/common SRCS+= tuklib_physmem.c tuklib_cpucores.c .PATH: ${LZMADIR}/api/lzma @@ -144,7 +144,7 @@ CFLAGS+= -DHAVE_CONFIG_H \ -I${LZMADIR}/lzma \ -I${LZMADIR}/delta \ -I${LZMADIR}/simple \ - -I${LZMADIR}/../common + -I${LZMADIR:H}/common DPADD+= ${LIBPTHREAD} LDADD+= -lpthread -- cgit v1.1 From 71542575af2defd7e2c3aedd99659124f683065e Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:56:38 +0000 Subject: MFC r312499: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This simplifies pathing in make/displayed output --- lib/libldns/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libldns/Makefile b/lib/libldns/Makefile index db4b989..5c9eed4 100644 --- a/lib/libldns/Makefile +++ b/lib/libldns/Makefile @@ -1,7 +1,7 @@ # $FreeBSD$ # Vendor sources and generated files -LDNSDIR = ${.CURDIR}/../../contrib/ldns +LDNSDIR = ${SRCTOP}/contrib/ldns .PATH: ${LDNSDIR} ${LDNSDIR}/compat -- cgit v1.1 From 41ea5ba4125fe59768be3f47254885f6a854b808 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:57:22 +0000 Subject: MFC r312500: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This simplifies pathing in make/displayed output --- lib/libkiconv/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libkiconv/Makefile b/lib/libkiconv/Makefile index bda505e..650f7e0 100644 --- a/lib/libkiconv/Makefile +++ b/lib/libkiconv/Makefile @@ -16,7 +16,7 @@ MLINKS+= kiconv.3 kiconv_add_xlat16_cspair.3 \ kiconv.3 kiconv_add_xlat16_cspairs.3 \ kiconv.3 kiconv_add_xlat16_table.3 -CFLAGS+= -I${.CURDIR}/../../sys +CFLAGS+= -I${SRCTOP}/sys WARNS?= 1 -- cgit v1.1 From 2b3dd72c57ac7e9bc292bf000cc33d73728b4b0f Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:58:24 +0000 Subject: MFC r312501: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This simplifies pathing in make/displayed output --- lib/libcom_err/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libcom_err/Makefile b/lib/libcom_err/Makefile index 78014ad..c19b2a8 100644 --- a/lib/libcom_err/Makefile +++ b/lib/libcom_err/Makefile @@ -4,7 +4,7 @@ LIB= com_err SRCS= com_err.c error.c INCS= ${COM_ERRDIR}/com_err.h ${COM_ERRDIR}/com_right.h MAN= com_err.3 -COM_ERRDIR= ${.CURDIR}/../../contrib/com_err +COM_ERRDIR= ${SRCTOP}/contrib/com_err CFLAGS+= -I${COM_ERRDIR} LDFLAGS= -Wl,--no-undefined -- cgit v1.1 From 2d3713151da8e647d3e49d2d54acef05cd47085b Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 06:59:03 +0000 Subject: MFC r312502: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This simplifies pathing in make/displayed output --- lib/libcompat/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libcompat/Makefile b/lib/libcompat/Makefile index fca86c7..a7d56a7 100644 --- a/lib/libcompat/Makefile +++ b/lib/libcompat/Makefile @@ -2,7 +2,7 @@ # $FreeBSD$ LIB= compat -CFLAGS+=-DLIBC_SCCS -DSYSLIBC_SCCS -I${.CURDIR}/../libc/locale +CFLAGS+=-DLIBC_SCCS -DSYSLIBC_SCCS -I${SRCTOP}/lib/libc/locale NO_PIC= WARNS?= 0 -- cgit v1.1 From acaf79a632211b221c1b3de58fb3ae3371c36fd4 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 07:00:31 +0000 Subject: MFC r312504: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This simplifies pathing in make/displayed output --- lib/libcxxrt/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libcxxrt/Makefile b/lib/libcxxrt/Makefile index d197361..1d14cfe 100644 --- a/lib/libcxxrt/Makefile +++ b/lib/libcxxrt/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -SRCDIR= ${.CURDIR}/../../contrib/libcxxrt +SRCDIR= ${SRCTOP}/contrib/libcxxrt SHLIB_MAJOR= 1 SHLIBDIR?= /lib -- cgit v1.1 From a345bd0dee6ea94e2427fea79bab3447d5e31391 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 07:01:17 +0000 Subject: MFC r312505: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This simplifies pathing in make/displayed output --- lib/libgssapi/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libgssapi/Makefile b/lib/libgssapi/Makefile index 3f016b4..3094631 100644 --- a/lib/libgssapi/Makefile +++ b/lib/libgssapi/Makefile @@ -2,7 +2,7 @@ LIB= gssapi SHLIB_MAJOR= 10 -VERSION_DEF= ${.CURDIR}/../libc/Versions.def +VERSION_DEF= ${SRCTOP}/lib/libc/Versions.def SYMBOL_MAPS= ${.CURDIR}/Symbol.map SRCS= -- cgit v1.1 From 8097e3756b1edfe55a9d70567ebba25915350127 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 07:02:04 +0000 Subject: MFC r312506: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This simplifies pathing in make/displayed output --- lib/libiconv_modules/Makefile.inc | 4 ++-- lib/libiconv_modules/mapper_parallel/Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libiconv_modules/Makefile.inc b/lib/libiconv_modules/Makefile.inc index 3b25374..d24c616 100644 --- a/lib/libiconv_modules/Makefile.inc +++ b/lib/libiconv_modules/Makefile.inc @@ -1,10 +1,10 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../libc/iconv +.PATH: ${SRCTOP}/lib/libc/iconv SHLIB_MAJOR= 4 WARNS?= 6 -CFLAGS+= -I${.CURDIR}/../../libc/iconv +CFLAGS+= -I${SRCTOP}/lib/libc/iconv CFLAGS+= -Dbool=_Bool diff --git a/lib/libiconv_modules/mapper_parallel/Makefile b/lib/libiconv_modules/mapper_parallel/Makefile index b79c3ad..0008665 100644 --- a/lib/libiconv_modules/mapper_parallel/Makefile +++ b/lib/libiconv_modules/mapper_parallel/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../mapper_serial +.PATH: ${.CURDIR:H}/mapper_serial SHLIB= mapper_parallel SRCS+= citrus_mapper_serial.c -- cgit v1.1 From cb0278a0b26f43bad19b0c8b0a42e0055ae2ec9e Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 07:03:10 +0000 Subject: MFC r312507: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This simplifies pathing in make/displayed output --- lib/libexecinfo/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libexecinfo/Makefile b/lib/libexecinfo/Makefile index 81fa82a..15520c2 100644 --- a/lib/libexecinfo/Makefile +++ b/lib/libexecinfo/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -LIBEXECINFO= ${.CURDIR}/../../contrib/libexecinfo +LIBEXECINFO= ${SRCTOP}/contrib/libexecinfo LIB= execinfo SHLIB_MAJOR= 1 -- cgit v1.1 From 5bd8521f17cacd2b36a8960967f7cd969cd7cd98 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 07:03:54 +0000 Subject: MFC r312508: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This simplifies pathing in make/displayed output --- lib/libexpat/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libexpat/Makefile b/lib/libexpat/Makefile index 9b641c1..389453d 100644 --- a/lib/libexpat/Makefile +++ b/lib/libexpat/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -EXPAT= ${.CURDIR}/../../contrib/expat +EXPAT= ${SRCTOP}/contrib/expat LIB= bsdxml SHLIBDIR?= /lib -- cgit v1.1 From 7f617ce48926e6fbb98fb8d19a3b69686d1a293f Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 07:11:43 +0000 Subject: MFC r312523: Add some basic -s flag testcases for cut(1) The remaining functionality seems to be covered in one form or another via the NetBSD ATF testcase. --- usr.bin/cut/tests/Makefile | 1 + usr.bin/cut/tests/cut2_test.sh | 51 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 usr.bin/cut/tests/cut2_test.sh diff --git a/usr.bin/cut/tests/Makefile b/usr.bin/cut/tests/Makefile index 7d8707d..c1abcc7 100644 --- a/usr.bin/cut/tests/Makefile +++ b/usr.bin/cut/tests/Makefile @@ -2,6 +2,7 @@ .include +ATF_TESTS_SH+= cut2_test NETBSD_ATF_TESTS_SH= cut_test FILESDIR= ${TESTSDIR} diff --git a/usr.bin/cut/tests/cut2_test.sh b/usr.bin/cut/tests/cut2_test.sh new file mode 100755 index 0000000..e5aaa9a --- /dev/null +++ b/usr.bin/cut/tests/cut2_test.sh @@ -0,0 +1,51 @@ +# +# Copyright (c) 2017 Dell EMC +# 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$ + +atf_test_case s_flag +s_flag_head() +{ + atf_set "descr" "Check -s flag" +} + +s_flag_body() +{ + cat >input< Date: Sat, 11 Feb 2017 07:13:12 +0000 Subject: MFC r312514: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This simplifies pathing in make/displayed output --- gnu/usr.bin/gdb/gdbserver/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnu/usr.bin/gdb/gdbserver/Makefile b/gnu/usr.bin/gdb/gdbserver/Makefile index f5cfd4c..fa46e6d 100644 --- a/gnu/usr.bin/gdb/gdbserver/Makefile +++ b/gnu/usr.bin/gdb/gdbserver/Makefile @@ -3,7 +3,7 @@ # Not elf specific so don't install in /usr/libexec/elf BINDIR=/usr/bin -GDBDIR= ${.CURDIR}/../../../../contrib/gdb +GDBDIR= ${SRCTOP}/contrib/gdb .PATH: ${GDBDIR}/gdb/signals .PATH: ${GDBDIR}/gdb/gdbserver .PATH: ${GDBDIR}/gdb -- cgit v1.1 From 90e3ade840a9690b3d0077885b405cf82db86063 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 07:14:45 +0000 Subject: MFC r312513: Use SRCTOP-relative paths to other directories instead of .CURDIR-relative ones This simplifies pathing in make/displayed output --- sys/modules/ath/Makefile | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/sys/modules/ath/Makefile b/sys/modules/ath/Makefile index 33a1650..1bd2eb9 100644 --- a/sys/modules/ath/Makefile +++ b/sys/modules/ath/Makefile @@ -31,8 +31,8 @@ ATH_RATE?= sample # tx rate control algorithm -.PATH: ${.CURDIR}/../../dev/ath -.PATH: ${.CURDIR}/../../dev/ath/ath_hal +.PATH: ${SRCTOP}/sys/dev/ath +.PATH: ${SRCTOP}/sys/dev/ath/ath_hal KMOD= if_ath SRCS= if_ath.c if_ath_alq.c if_ath_debug.c if_ath_keycache.c if_ath_sysctl.c @@ -46,7 +46,7 @@ SRCS+= device_if.h bus_if.h pci_if.h opt_inet.h opt_ath.h opt_ah.h opt_wlan.h # # AR5210 support; these are first generation 11a-only devices. # -.PATH: ${.CURDIR}/../../dev/ath/ath_hal/ar5210 +.PATH: ${SRCTOP}/sys/dev/ath/ath_hal/ar5210 SRCS+= ah_eeprom_v1.c \ ar5210_attach.c ar5210_beacon.c ar5210_interrupts.c \ ar5210_keycache.c ar5210_misc.c ar5210_phy.c ar5210_power.c \ @@ -56,7 +56,7 @@ SRCS+= ah_eeprom_v1.c \ # AR5211 support; these are second generation 11b/g/a devices # (but 11g was OFDM only and is not supported). # -.PATH: ${.CURDIR}/../../dev/ath/ath_hal/ar5211 +.PATH: ${SRCTOP}/sys/dev/ath/ath_hal/ar5211 SRCS+= ar5211_attach.c ar5211_beacon.c ar5211_interrupts.c \ ar5211_keycache.c ar5211_misc.c ar5211_phy.c ar5211_power.c \ ar5211_recv.c ar5211_reset.c ar5211_xmit.c @@ -64,7 +64,7 @@ SRCS+= ar5211_attach.c ar5211_beacon.c ar5211_interrupts.c \ # # AR5212 support; this covers all other pci/cardbus legacy parts. # -.PATH: ${.CURDIR}/../../dev/ath/ath_hal/ar5212 +.PATH: ${SRCTOP}/sys/dev/ath/ath_hal/ar5212 SRCS+= ar5212_ani.c ar5212_attach.c ar5212_beacon.c ar5212_eeprom.c \ ar5212_gpio.c ar5212_interrupts.c ar5212_keycache.c ar5212_misc.c \ ar5212_phy.c ar5212_power.c ar5212_recv.c ar5212_reset.c \ @@ -85,7 +85,7 @@ SRCS+= ar5413.c # NB: 9160 depends on 5416 but 5416 does not require 9160 # # + 5416 (Owl) -.PATH: ${.CURDIR}/../../dev/ath/ath_hal/ar5416 +.PATH: ${SRCTOP}/sys/dev/ath/ath_hal/ar5416 SRCS+= ah_eeprom_v14.c ah_eeprom_v4k.c \ ar5416_ani.c ar5416_attach.c ar5416_beacon.c ar5416_btcoex.c \ ar5416_cal.c ar5416_cal_iq.c ar5416_cal_adcgain.c ar5416_cal_adcdc.c \ @@ -97,7 +97,7 @@ SRCS+= ah_eeprom_v14.c ah_eeprom_v4k.c \ SRCS+= ar2133.c # + AR9160 (Sowl) -.PATH: ${.CURDIR}/../../dev/ath/ath_hal/ar9001 +.PATH: ${SRCTOP}/sys/dev/ath/ath_hal/ar9001 SRCS+= ar9160_attach.c # + AR9130 - (Sowl) - Embedded (AR913x SoC) @@ -111,7 +111,7 @@ SRCS+= ar9130_attach.c ar9130_eeprom.c ar9130_phy.c # AR9002 series chips # + AR9220/AR9280 - Merlin -.PATH: ${.CURDIR}/../../dev/ath/ath_hal/ar9002 +.PATH: ${SRCTOP}/sys/dev/ath/ath_hal/ar9002 SRCS+= ar9280.c ar9280_attach.c ar9280_olc.c # + AR9285 - Kite @@ -119,13 +119,13 @@ SRCS+= ar9285.c ar9285_reset.c ar9285_attach.c ar9285_cal.c ar9285_phy.c SRCS+= ar9285_diversity.c ar9285_btcoex.c # + AR9287 - Kiwi -.PATH: ${.CURDIR}/../../dev/ath/ath_hal +.PATH: ${SRCTOP}/sys/dev/ath/ath_hal SRCS+= ah_eeprom_9287.c -.PATH: ${.CURDIR}/../../dev/ath/ath_hal/ar9002 +.PATH: ${SRCTOP}/sys/dev/ath/ath_hal/ar9002 SRCS+= ar9287.c ar9287_reset.c ar9287_attach.c ar9287_cal.c ar9287_olc.c # + AR9300 HAL -.PATH: ${.CURDIR}/../../contrib/dev/ath/ath_hal/ar9300 +.PATH: ${SRCTOP}/sys/contrib/dev/ath/ath_hal/ar9300 SRCS+= ar9300_interrupts.c ar9300_radar.c ar9300_ani.c ar9300_keycache.c SRCS+= ar9300_radio.c ar9300_xmit.c ar9300_attach.c ar9300_mci.c ar9300_stub.c SRCS+= ar9300_xmit_ds.c ar9300_beacon.c ar9300_misc.c ar9300_recv.c @@ -135,22 +135,22 @@ SRCS+= ar9300_power.c ar9300_timer.c # NB: rate control is bound to the driver by symbol names so only pick one .if ${ATH_RATE} == "sample" -.PATH: ${.CURDIR}/../../dev/ath/ath_rate/sample +.PATH: ${SRCTOP}/sys/dev/ath/ath_rate/sample SRCS+= sample.c .elif ${ATH_RATE} == "onoe" -.PATH: ${.CURDIR}/../../dev/ath/ath_rate/onoe +.PATH: ${SRCTOP}/sys/dev/ath/ath_rate/onoe SRCS+= onoe.c .elif ${ATH_RATE} == "amrr" -.PATH: ${.CURDIR}/../../dev/ath/ath_rate/amrr +.PATH: ${SRCTOP}/sys/dev/ath/ath_rate/amrr SRCS+= amrr.c .endif # DFS -.PATH: ${.CURDIR}/../../dev/ath/ath_dfs/null +.PATH: ${SRCTOP}/sys/dev/ath/ath_dfs/null SRCS+= dfs_null.c -CFLAGS+= -I. -I${.CURDIR}/../../dev/ath -I${.CURDIR}/../../dev/ath/ath_hal -CFLAGS+= -I. -I${.CURDIR}/../../contrib/dev/ath/ath_hal/ +CFLAGS+= -I. -I${SRCTOP}/sys/dev/ath -I${SRCTOP}/sys/dev/ath/ath_hal +CFLAGS+= -I. -I${SRCTOP}/sys/contrib/dev/ath/ath_hal/ .if !defined(KERNBUILDDIR) opt_ah.h: -- cgit v1.1 From be2fb88bb5cf67a97a0d817e190baf58891b2b67 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 07:35:27 +0000 Subject: MFC r312102,r312108: r312102: Note that sys/types.h is required on FreeBSD for kqueue(2), unlike NetBSD r312108: Delete trailing whitespace and use __arraycount instead of nitems in contrib code --- contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c | 12 ++++++------ contrib/netbsd-tests/lib/libc/gen/t_sleep.c | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c index 78313cd..2085b9e 100644 --- a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c +++ b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c @@ -60,16 +60,16 @@ get_different_scheduler(void) /* get current schedule policy */ scheduler = sched_getscheduler(0); - for (i = 0; i < nitems(schedulers); i++) { + for (i = 0; i < __arraycount(schedulers); i++) { if (schedulers[i] == scheduler) break; } - ATF_REQUIRE_MSG(i < nitems(schedulers), + ATF_REQUIRE_MSG(i < __arraycount(schedulers), "Unknown current scheduler %d", scheduler); - + /* new scheduler */ i++; - if (i >= nitems(schedulers)) + if (i >= __arraycount(schedulers)) i = 0; return schedulers[i]; } @@ -85,7 +85,7 @@ get_different_priority(int scheduler) sched_getparam(0, ¶m); priority = param.sched_priority; - + /* * Change numerical value of the priority, to ensure that it * was set for the spawned child. @@ -127,7 +127,7 @@ ATF_TC_BODY(t_spawnattr, tc) scheduler = get_different_scheduler(); priority = get_different_priority(scheduler); sp.sched_priority = priority; - + sigemptyset(&sig); sigaddset(&sig, SIGUSR1); diff --git a/contrib/netbsd-tests/lib/libc/gen/t_sleep.c b/contrib/netbsd-tests/lib/libc/gen/t_sleep.c index 5e36456..e85867a 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_sleep.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_sleep.c @@ -27,6 +27,7 @@ */ #ifdef __FreeBSD__ +/* kqueue(2) on FreeBSD requires sys/types.h for uintptr_t; NetBSD doesn't. */ #include #endif #include -- cgit v1.1 From 180753ef179b1c503f44e7625c467758dd6f3c4d Mon Sep 17 00:00:00 2001 From: cy Date: Sat, 11 Feb 2017 18:10:55 +0000 Subject: MFC r311950 (by bz): Get rid of a compiler warning which I saw too often. Include netinet/in.h before ip_compat.t which will then check if IPPROTO_IPIP is defined or not. Doing it the other way round, ip_compat.h would not find it defined and netinet/in.h then redefine it. --- sys/contrib/ipfilter/netinet/ip_fil.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/contrib/ipfilter/netinet/ip_fil.h b/sys/contrib/ipfilter/netinet/ip_fil.h index 01ccd1d..170cc53 100644 --- a/sys/contrib/ipfilter/netinet/ip_fil.h +++ b/sys/contrib/ipfilter/netinet/ip_fil.h @@ -11,6 +11,10 @@ #ifndef __IP_FIL_H__ #define __IP_FIL_H__ +#if !defined(linux) || !defined(_KERNEL) +# include +#endif + #include "netinet/ip_compat.h" #include "netinet/ipf_rb.h" #if NETBSD_GE_REV(104040000) @@ -24,10 +28,6 @@ # endif #endif -#if !defined(linux) || !defined(_KERNEL) -# include -#endif - #ifndef SOLARIS # if defined(sun) && (defined(__svr4__) || defined(__SVR4)) # define SOLARIS 1 -- cgit v1.1 From 15592b02ebadc327c4f46d9f53f99b26f7798b2e Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 11 Feb 2017 20:46:49 +0000 Subject: Unbreak lib/csu for i386 and amd64 (MK_LIB32 == yes) after r313582 I accidentally goofed up the directory for lib/libc in the CFLAGS This is a direct commit to this branch Pointyhat to: ngie --- lib/csu/i386-elf/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/csu/i386-elf/Makefile b/lib/csu/i386-elf/Makefile index 39d1a67..dd387b9 100644 --- a/lib/csu/i386-elf/Makefile +++ b/lib/csu/i386-elf/Makefile @@ -9,7 +9,7 @@ FILESGRP= ${LIBGRP} FILESMODE= ${LIBMODE} FILESDIR= ${LIBDIR} CFLAGS+= -I${.CURDIR:H}/common \ - -I${SRCTOP}/libc/include + -I${SRCTOP}/lib/libc/include CLEANFILES= ${FILES} crt1_c.o crt1_s.o gcrt1_c.o Scrt1_c.o CLEANFILES+= crt1_c.s gcrt1_c.s Scrt1_c.s -- cgit v1.1 From 16f159656f0b3e31a58c10c817fb70d11aaef12a Mon Sep 17 00:00:00 2001 From: ngie Date: Sun, 12 Feb 2017 09:27:34 +0000 Subject: MFC r313273: style(9) cleanup - Delete trailing whitespace - Fix alignment/variable sorting - Delete single-line enclosing braces --- sbin/kldload/kldload.c | 59 ++++++++++++++++++++------------------------------ 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/sbin/kldload/kldload.c b/sbin/kldload/kldload.c index 3891f33..fc8c8c4 100644 --- a/sbin/kldload/kldload.c +++ b/sbin/kldload/kldload.c @@ -41,9 +41,6 @@ __FBSDID("$FreeBSD$"); #define PATHCTL "kern.module_path" -static int path_check(const char *, int); -static void usage(void); - /* * Check to see if the requested module is specified as a filename with no * path. If so and if a file by the same name exists in the module path, @@ -52,43 +49,37 @@ static void usage(void); static int path_check(const char *kldname, int quiet) { - int mib[5], found; - size_t miblen, pathlen; - char kldpath[MAXPATHLEN]; char *path, *tmppath, *element; struct stat sb; + int mib[5]; + char kldpath[MAXPATHLEN]; + size_t miblen, pathlen; dev_t dev; ino_t ino; + int found; - if (strchr(kldname, '/') != NULL) { + if (strchr(kldname, '/') != NULL) return (0); - } - if (strstr(kldname, ".ko") == NULL) { + if (strstr(kldname, ".ko") == NULL) return (0); - } - if (stat(kldname, &sb) != 0) { + if (stat(kldname, &sb) != 0) return (0); - } found = 0; dev = sb.st_dev; ino = sb.st_ino; miblen = sizeof(mib) / sizeof(mib[0]); - if (sysctlnametomib(PATHCTL, mib, &miblen) != 0) { + if (sysctlnametomib(PATHCTL, mib, &miblen) != 0) err(1, "sysctlnametomib(%s)", PATHCTL); - } - if (sysctl(mib, miblen, NULL, &pathlen, NULL, 0) == -1) { + if (sysctl(mib, miblen, NULL, &pathlen, NULL, 0) == -1) err(1, "getting path: sysctl(%s) - size only", PATHCTL); - } path = malloc(pathlen + 1); - if (path == NULL) { + if (path == NULL) err(1, "allocating %lu bytes for the path", (unsigned long)pathlen + 1); - } - if (sysctl(mib, miblen, path, &pathlen, NULL, 0) == -1) { + if (sysctl(mib, miblen, path, &pathlen, NULL, 0) == -1) err(1, "getting path: sysctl(%s)", PATHCTL); - } tmppath = path; while ((element = strsep(&tmppath, ";")) != NULL) { @@ -97,39 +88,36 @@ path_check(const char *kldname, int quiet) strlcat(kldpath, "/", MAXPATHLEN); } strlcat(kldpath, kldname, MAXPATHLEN); - - if (stat(kldpath, &sb) == -1) { + + if (stat(kldpath, &sb) == -1) continue; - } found = 1; if (sb.st_dev != dev || sb.st_ino != ino) { - if (!quiet) { + if (!quiet) warnx("%s will be loaded from %s, not the " "current directory", kldname, element); - } break; - } else if (sb.st_dev == dev && sb.st_ino == ino) { + } else if (sb.st_dev == dev && sb.st_ino == ino) break; - } } free(path); - + if (!found) { - if (!quiet) { + if (!quiet) warnx("%s is not in the module path", kldname); - } return (-1); } - + return (0); } static void usage(void) { + fprintf(stderr, "usage: kldload [-nqv] file ...\n"); exit(1); } @@ -138,17 +126,17 @@ int main(int argc, char** argv) { int c; + int check_loaded; int errors; int fileid; - int verbose; int quiet; - int check_loaded; + int verbose; errors = 0; verbose = 0; quiet = 0; check_loaded = 0; - + while ((c = getopt(argc, argv, "nqv")) != -1) { switch (c) { case 'q': @@ -204,9 +192,8 @@ main(int argc, char** argv) printf("Loaded %s, id=%d\n", argv[0], fileid); } - } else { + } else errors++; - } argv++; } -- cgit v1.1 From 7f744e86ff06be037edeee6f6535e91834c87711 Mon Sep 17 00:00:00 2001 From: jilles Date: Sun, 12 Feb 2017 18:52:01 +0000 Subject: MFC r313174: Clean up documentation of AF_UNIX control messages. Document AF_UNIX control messages in unix(4) only, not split between unix(4) and recv(2). Also, warn about LOCAL_CREDS effective uid/gid fields, since the write could be from a setuid or setgid program (with the explicit SCM_CREDS and LOCAL_PEERCRED, the credentials are read at such a time that it can be assumed that the process intends for them to be used in this context). --- lib/libc/sys/recv.2 | 55 +++------------------------------- share/man/man4/unix.4 | 81 +++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 76 insertions(+), 60 deletions(-) diff --git a/lib/libc/sys/recv.2 b/lib/libc/sys/recv.2 index e0a1f04..7ad7aa7 100644 --- a/lib/libc/sys/recv.2 +++ b/lib/libc/sys/recv.2 @@ -28,7 +28,7 @@ .\" @(#)recv.2 8.3 (Berkeley) 2/21/94 .\" $FreeBSD$ .\" -.Dd March 19, 2013 +.Dd February 3, 2017 .Dt RECV 2 .Os .Sh NAME @@ -218,57 +218,10 @@ with no data buffer provided immediately after an .Fn accept system call. .Pp -Open file descriptors are now passed as ancillary data for +With .Dv AF_UNIX -domain sockets, with -.Fa cmsg_level -set to -.Dv SOL_SOCKET -and -.Fa cmsg_type -set to -.Dv SCM_RIGHTS . -The close-on-exec flag on received descriptors is set according to the -.Dv MSG_CMSG_CLOEXEC -flag passed to -.Fn recvmsg . -.Pp -Process credentials can also be passed as ancillary data for -.Dv AF_UNIX -domain sockets using a -.Fa cmsg_type -of -.Dv SCM_CREDS . -In this case, -.Fa cmsg_data -should be a structure of type -.Fa cmsgcred , -which is defined in -.In sys/socket.h -as follows: -.Bd -literal -struct cmsgcred { - pid_t cmcred_pid; /* PID of sending process */ - uid_t cmcred_uid; /* real UID of sending process */ - uid_t cmcred_euid; /* effective UID of sending process */ - gid_t cmcred_gid; /* real GID of sending process */ - short cmcred_ngroups; /* number or groups */ - gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ -}; -.Ed -.Pp -If a sender supplies ancillary data with enough space for the above struct -tagged as -.Dv SCM_CREDS -control message type to the -.Fn sendmsg -system call, then kernel will fill in the credential information of the -sending process and deliver it to the receiver. -Since receiver usually has no control over a sender, this method of retrieving -credential information isn't reliable. -For reliable retrieval of remote side credentials it is advised to use the -.Dv LOCAL_CREDS -socket option on the receiving socket. +domain sockets, ancillary data can be used to pass file descriptors and +process credentials. See .Xr unix 4 for details. diff --git a/share/man/man4/unix.4 b/share/man/man4/unix.4 index c53cc42..0e8470f 100644 --- a/share/man/man4/unix.4 +++ b/share/man/man4/unix.4 @@ -32,7 +32,7 @@ .\" @(#)unix.4 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd March 19, 2013 +.Dd February 3, 2017 .Dt UNIX 4 .Os .Sh NAME @@ -123,12 +123,12 @@ of a or .Xr sendto 2 must be writable. -.Sh PASSING FILE DESCRIPTORS +.Sh CONTROL MESSAGES The .Ux Ns -domain sockets support the communication of .Ux -file descriptors through the use of the +file descriptors and process credentials through the use of the .Va msg_control field in the .Fa msg @@ -136,13 +136,12 @@ argument to .Xr sendmsg 2 and .Xr recvmsg 2 . -.Pp -Any valid descriptor may be sent in a message. -The file descriptor(s) to be passed are described using a +The items to be passed are described using a .Vt "struct cmsghdr" that is defined in the include file .In sys/socket.h . -The type of the message is +.Pp +To send file descriptors, the type of the message is .Dv SCM_RIGHTS , and the data portion of the messages is an array of integers representing the file descriptors to be passed. @@ -165,6 +164,39 @@ call. Descriptors that are awaiting delivery, or that are purposely not received, are automatically closed by the system when the destination socket is closed. +.Pp +Credentials of the sending process can be transmitted explicitly using a +control message of type +.Dv SCM_CREDS +with a data portion of type +.Vt "struct cmsgcred" , +defined in +.In sys/socket.h +as follows: +.Bd -literal +struct cmsgcred { + pid_t cmcred_pid; /* PID of sending process */ + uid_t cmcred_uid; /* real UID of sending process */ + uid_t cmcred_euid; /* effective UID of sending process */ + gid_t cmcred_gid; /* real GID of sending process */ + short cmcred_ngroups; /* number of groups */ + gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ +}; +.Ed +.Pp +The sender should pass a zeroed buffer which will be filled in by the system. +.Pp +The group list is truncated to at most +.Dv CMGROUP_MAX +GIDs. +.Pp +The process ID +.Fa cmcred_pid +should not be looked up (such as via the +.Dv KERN_PROC_PID +sysctl) for making security decisions. +The sending process could have exited and its process ID already been +reused for a new process. .Sh SOCKET OPTIONS .Tn UNIX domain sockets support a number of socket options which can be set with @@ -180,7 +212,13 @@ or a .Dv SOCK_STREAM socket. This option provides a mechanism for the receiver to -receive the credentials of the process as a +receive the credentials of the process calling +.Xr write 2 , +.Xr send 2 , +.Xr sendto 2 +or +.Xr sendmsg 2 +as a .Xr recvmsg 2 control message. The @@ -205,6 +243,10 @@ struct sockcred { }; .Ed .Pp +The current implementation truncates the group list to at most +.Dv CMGROUP_MAX +groups. +.Pp The .Fn SOCKCREDSIZE macro computes the size of the @@ -225,7 +267,28 @@ On and .Dv SOCK_SEQPACKET sockets credentials are passed only on the first read from a socket, -then system clears the option on socket. +then the system clears the option on the socket. +.Pp +This option and the above explicit +.Vt "struct cmsgcred" +both use the same value +.Dv SCM_CREDS +but incompatible control messages. +If this option is enabled and the sender attached a +.Dv SCM_CREDS +control message with a +.Vt "struct cmsgcred" , +it will be discarded and a +.Vt "struct sockcred" +will be included. +.Pp +Many setuid programs will +.Xr write 2 +data at least partially controlled by the invoker, +such as error messages. +Therefore, a message accompanied by a particular +.Fa sc_euid +value should not be trusted as being from that user. .It Dv LOCAL_CONNWAIT Used with .Dv SOCK_STREAM -- cgit v1.1 From fe349b3d09938660e2a169fe5511c9b93d6fef8e Mon Sep 17 00:00:00 2001 From: ken Date: Mon, 13 Feb 2017 16:11:37 +0000 Subject: MFC r313568: ------------------------------------------------------------------------ r313568 | ken | 2017-02-10 15:02:45 -0700 (Fri, 10 Feb 2017) | 68 lines Change the isp(4) driver to not adjust the tag type for REQUEST SENSE. The isp(4) driver was changing the tag type for REQUEST SENSE commands to Head of Queue, when the CAM CCB flag CAM_TAG_ACTION_VALID was NOT set. CAM_TAG_ACTION_VALID is set when the tag action in the XPT_SCSI_IO is not CAM_TAG_ACTION_NONE and when the target has tagged queueing turned on. In most cases when CAM_TAG_ACTION_VALID is not set, it is because the target is not doing tagged queueing. In those cases, trying to send a Head of Queue tag may cause problems. Instead, default to sending a simple tag. IBM tape drives claim to support tagged queueing in their standard Inquiry data, but have the DQue bit set in the control mode page (mode page 10). CAM correctly detects that these drives do not support tagged queueing, and clears the CAM_TAG_ACTION_VALID flag on CCBs sent down to the drives. This caused the isp(4) driver to go down the path of setting the tag action to a default value, and for Request Sense commands only, set the tag action to Head of Queue. If an IBM tape drive does get a Head of Queue tag, it rejects it with Invalid Message Error (0x49,0x00). (The Qlogic firmware translates that to a Transport Error, which the driver translates to an Unrecoverable HBA Error, or CAM_UNREC_HBA_ERROR.) So, by default, it wasn't possible to get a good response from a REQUEST SENSE to an FC-attached IBM tape drive with the isp(4) driver. IBM tape drives (tested on an LTO-5 with G9N1 firmware and a TS1150 with 4470 firmware) also have a bug in that sending a command with a non-simple tag attribute breaks the tape drive's Command Reference Number (CRN) accounting and causes it to ignore all subsequent commands because it and the initiator disagree about the next expected CRN. The drives do reject the initial command with a head of queue tag with an Invalid Message Error (0x49,0x00), but after that they ignore any subsequent commands. IBM confirmed that it is a bug, and sent me test firmware that fixes the bug. However tape drives in the field will still exhibit the bug until they are upgraded. Request Sense is not often sent to targets because most errors are reported automatically through autosense in Fibre Channel and other modern transports. ("Modern" meaning post SCSI-2.) So this is not an error that would crop up frequently. But Request Sense is useful on tape devices to report status information, aside from error reporting. This problem is less serious without FC-Tape features turned on, specifically precise delivery of commands (which enables Command Reference Numbers), enabled on the target and initiator. Without FC-Tape features turned on, the target would return an error and things would continue on. And it also does not cause problems for targets that do tagged queueing, because in those cases the isp(4) driver just uses the tag type that is specified in the CCB, assuming the CAM_TAG_ACTION_VALID flag is set, and defaults to sending a Simple tag action if it isn't an ordered or head of queue tag. sys/dev/isp/isp.c: In isp_start(), don't try to send Request Sense commands with the Head of Queue tag attribute if the CCB doesn't have a valid tag action. The tag action likely isn't valid because the target doesn't support tagged queueing. Sponsored by: Spectra Logic ------------------------------------------------------------------------ --- sys/dev/isp/isp.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/sys/dev/isp/isp.c b/sys/dev/isp/isp.c index 9d38f60..c77bda5 100644 --- a/sys/dev/isp/isp.c +++ b/sys/dev/isp/isp.c @@ -4451,11 +4451,7 @@ isp_start(XS_T *xs) if (XS_TAG_P(xs)) { ttype = XS_TAG_TYPE(xs); } else { - if (XS_CDBP(xs)[0] == 0x3) { - ttype = REQFLAG_HTAG; - } else { - ttype = REQFLAG_STAG; - } + ttype = REQFLAG_STAG; } if (ttype == REQFLAG_OTAG) { ttype = FCP_CMND_TASK_ATTR_ORDERED; @@ -4479,14 +4475,7 @@ isp_start(XS_T *xs) if (XS_TAG_P(xs)) { ((ispreqt2_t *)reqp)->req_flags = XS_TAG_TYPE(xs); } else { - /* - * If we don't know what tag to use, use HEAD OF QUEUE - * for Request Sense or Simple. - */ - if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */ - ((ispreqt2_t *)reqp)->req_flags = REQFLAG_HTAG; - else - ((ispreqt2_t *)reqp)->req_flags = REQFLAG_STAG; + ((ispreqt2_t *)reqp)->req_flags = REQFLAG_STAG; } } else { sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs)); -- cgit v1.1 From 2798b4fb758ec2f3622b0cc11edfe86649e78d1b Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 14 Feb 2017 04:38:37 +0000 Subject: MFC r313358,r313360: r313358: Sort sys/ #includes and zap an unnecessary trailing space nearby r313360: Sort sys/ #includes some more --- usr.sbin/syslogd/syslogd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 6e6d48a..2cb9304 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -79,15 +79,15 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include -#include -#include #include -#include -#include -#include #include +#include +#include #include +#include +#include +#include +#include #include #include -- cgit v1.1 From 7a6ce43b47d0f1fe0d996bc88e833da9dae841b8 Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 14 Feb 2017 04:42:47 +0000 Subject: MFC r313377: Expect :floatunditf to fail on FreeBSD/i386 The precision error on FreeBSD/i386 doesn't match the expected output in long double form. --- contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c b/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c index ef372f7..c3417bb 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c @@ -119,6 +119,11 @@ ATF_TC_BODY(floatunditf, tc) #else size_t i; +#if defined(__FreeBSD__) && defined(__i386__) + atf_tc_expect_fail("the floating point error on FreeBSD/i386 doesn't " + "match the expected floating point error on NetBSD"); +#endif + for (i = 0; i < __arraycount(testcases); ++i) ATF_CHECK_MSG( testcases[i].ld == (long double)testcases[i].u64, -- cgit v1.1 From 44e806ba3aa0d53f31bdef57fb11f38ffdd6d447 Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 14 Feb 2017 04:46:19 +0000 Subject: MFC r313376: Fix :hexadecimal_floating_point on i386 Don't exclude i386 from LDBL_MANT_DIG == 64; it works properly in that case. While here, replace strcmp + atf_tc_fail with ATF_CHECK_MSG for 2 reasons: - Gather as many results as possible instead of failing early and not testing the rest of the cases. - Simplify logic when checking test inputs vs outputs and printing test result. Tested on: amd64, i386 --- lib/libc/tests/stdio/printfloat_test.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/libc/tests/stdio/printfloat_test.c b/lib/libc/tests/stdio/printfloat_test.c index 8c02bec..6655680 100644 --- a/lib/libc/tests/stdio/printfloat_test.c +++ b/lib/libc/tests/stdio/printfloat_test.c @@ -70,22 +70,19 @@ _testfmt(const char *result, const char *argstr, const char *fmt,...) va_copy(ap2, ap); smash_stack(); vsnprintf(s, sizeof(s), fmt, ap); - if (strcmp(result, s) != 0) { - atf_tc_fail( - "printf(\"%s\", %s) ==> [%s], expected [%s]", - fmt, argstr, s, result); - } + ATF_CHECK_MSG(strcmp(result, s) == 0, + "printf(\"%s\", %s) ==> [%s], expected [%s]", + fmt, argstr, s, result); smash_stack(); mbstowcs(ws, s, BUF - 1); mbstowcs(wfmt, fmt, BUF - 1); mbstowcs(wresult, result, BUF - 1); vswprintf(ws, sizeof(ws) / sizeof(ws[0]), wfmt, ap2); - if (wcscmp(wresult, ws) != 0) { - atf_tc_fail( - "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]", - wfmt, argstr, ws, wresult); - } + ATF_CHECK_MSG(wcscmp(wresult, ws) == 0, + "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]", + wfmt, argstr, ws, wresult); + va_end(ap); va_end(ap2); } @@ -318,7 +315,7 @@ ATF_TC_BODY(hexadecimal_floating_point, tc) testfmt("0x1p-1074", "%a", 0x1p-1074); testfmt("0x1.2345p-1024", "%a", 0x1.2345p-1024); -#if (LDBL_MANT_DIG == 64) && !defined(__i386__) +#if (LDBL_MANT_DIG == 64) testfmt("0x1.921fb54442d18468p+1", "%La", 0x3.243f6a8885a308dp0L); testfmt("0x1p-16445", "%La", 0x1p-16445L); testfmt("0x1.30ecap-16381", "%La", 0x9.8765p-16384L); -- cgit v1.1 From ad0ecc0d7e6ae464befdc0ad2954a0eb5182b0d4 Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 14 Feb 2017 04:49:24 +0000 Subject: MFC r313378,r313379: r313378: Wrap strcmp/wcscmp calls with ATF_CHECK_MSG and drop atf_tc_fail use The reasoning here was the same as what was done in r313376: - Gather as many results as possible instead of failing early and not testing the rest of the cases. - Simplify logic when checking test inputs vs outputs and printing test result. r313379: Expect :int_within_limits to fail when ptrdiff_t/*intmax_t differ in base type The %t{d,u} (ptrdiff_t) tests fail for the following reasons: - ptrdiff_t is by definition int32_t on !LP64 architectures and int64_t on LP64 architectures. - intmax_t is by definition fixed to int64_t on all architectures. - Some of the code in lib/libc/stdio/... is promoting ptrdiff_t to *intmax_t when parsing/representing the value. PR: 191674 --- lib/libc/tests/stdio/printbasic_test.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/libc/tests/stdio/printbasic_test.c b/lib/libc/tests/stdio/printbasic_test.c index 7f7c6cb..322e747 100644 --- a/lib/libc/tests/stdio/printbasic_test.c +++ b/lib/libc/tests/stdio/printbasic_test.c @@ -78,22 +78,19 @@ _testfmt(const char *result, const char *argstr, const char *fmt,...) va_copy(ap2, ap); smash_stack(); vsnprintf(s, sizeof(s), fmt, ap); - if (strcmp(result, s) != 0) { - atf_tc_fail( - "printf(\"%s\", %s) ==> [%s], expected [%s]", - fmt, argstr, s, result); - } + ATF_CHECK_MSG(strcmp(result, s) == 0, + "printf(\"%s\", %s) ==> [%s], expected [%s]", + fmt, argstr, s, result); smash_stack(); mbstowcs(ws, s, BUF - 1); mbstowcs(wfmt, fmt, BUF - 1); mbstowcs(wresult, result, BUF - 1); vswprintf(ws, sizeof(ws) / sizeof(ws[0]), wfmt, ap2); - if (wcscmp(wresult, ws) != 0) { - atf_tc_fail( - "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]", - wfmt, argstr, ws, wresult); - } + ATF_CHECK_MSG(wcscmp(wresult, ws) == 0, + "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]", + wfmt, argstr, ws, wresult); + va_end(ap); va_end(ap2); } @@ -114,6 +111,11 @@ ATF_TC_BODY(int_within_limits, tc) testfmt("-1", "%jd", (intmax_t)-1); testfmt(S_UINT64MAX, "%ju", UINT64_MAX); + if (sizeof(ptrdiff_t) != sizeof(uintmax_t)) + atf_tc_expect_fail("the %%t qualifier is broken on 32-bit " + "platforms where there's a mismatch between ptrdiff_t and " + "uintmax_t's type width; bug # 191674"); + testfmt("-1", "%td", (ptrdiff_t)-1); testfmt(S_SIZEMAX, "%tu", (size_t)-1); -- cgit v1.1 From cf0f51ca17160dddf24b92f66fd12a8a42be30e9 Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 14 Feb 2017 04:52:24 +0000 Subject: MFC r313356: Fix typos in comments (returing -> returning) --- sys/netpfil/ipfw/dn_heap.h | 2 +- usr.sbin/syslogd/syslogd.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/ipfw/dn_heap.h b/sys/netpfil/ipfw/dn_heap.h index c95473a..d51d9b0 100644 --- a/sys/netpfil/ipfw/dn_heap.h +++ b/sys/netpfil/ipfw/dn_heap.h @@ -85,7 +85,7 @@ enum { * HEAP_TOP() returns a pointer to the top element of the heap, * but makes no checks on its existance (XXX should we change ?) * - * heap_extract() removes the entry at the top, returing the pointer. + * heap_extract() removes the entry at the top, returning the pointer. * (the key should have been read before). * * heap_scan() invokes a callback on each entry of the heap. diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 2cb9304..5dd32ab 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -2129,7 +2129,7 @@ markit(void) /* * fork off and become a daemon, but wait for the child to come online - * before returing to the parent, or we get disk thrashing at boot etc. + * before returning to the parent, or we get disk thrashing at boot etc. * Set a timer so we don't hang forever if it wedges. */ static int -- cgit v1.1 From d407e4773f76a8350b2cbda824163adcfdbe3951 Mon Sep 17 00:00:00 2001 From: avg Date: Tue, 14 Feb 2017 13:45:38 +0000 Subject: MFC r312991: put very expensive sanity checks of advisory locks under DIAGNOSTIC Sponsored by: Panzura --- sys/kern/kern_lockf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_lockf.c b/sys/kern/kern_lockf.c index a0a3789..1740d85 100644 --- a/sys/kern/kern_lockf.c +++ b/sys/kern/kern_lockf.c @@ -687,7 +687,7 @@ retry_setlock: break; } -#ifdef INVARIANTS +#ifdef DIAGNOSTIC /* * Check for some can't happen stuff. In this case, the active * lock list becoming disordered or containing mutually @@ -915,7 +915,7 @@ lf_add_edge(struct lockf_entry *x, struct lockf_entry *y) struct lockf_edge *e; int error; -#ifdef INVARIANTS +#ifdef DIAGNOSTIC LIST_FOREACH(e, &x->lf_outedges, le_outlink) KASSERT(e->le_to != y, ("adding lock edge twice")); #endif -- cgit v1.1 From fafa7b31df860d1913826def1e1342e032042399 Mon Sep 17 00:00:00 2001 From: asomers Date: Tue, 14 Feb 2017 21:02:27 +0000 Subject: MFC r311349, r311445 r311349: tabs -> spaces in etc/mtree MFC after: 4 weeks r311445: Fix typo from r311349 Reported by: lwhsu Pointy-hat-to: asomers MFC after: 4 weeks X-MFC-with: 311349 --- etc/mtree/BSD.tests.dist | 4 ++-- etc/mtree/BSD.var.dist | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index 61ff404..2732a0a 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -566,8 +566,8 @@ .. .. .. - bsdcat - .. + bsdcat + .. calendar .. cmp diff --git a/etc/mtree/BSD.var.dist b/etc/mtree/BSD.var.dist index 4082ad4..2bbc9db 100644 --- a/etc/mtree/BSD.var.dist +++ b/etc/mtree/BSD.var.dist @@ -28,7 +28,7 @@ /set gname=wheel backups .. - cache mode=0755 + cache mode=0755 .. crash .. -- cgit v1.1 From 50ab11fce02e8a54c23784af5e534a8084b374d6 Mon Sep 17 00:00:00 2001 From: asomers Date: Wed, 15 Feb 2017 00:16:52 +0000 Subject: MFC r311893, r313008, r313081 I had to modify the tests slightly for the MFC to stable/10, because stable/10 lacks r294037, which enabled /sbin/md5 to work on md(4) devices. r311893: ATFify the geom gate tests. This ensures their cleanup routines will be run even if they should timeout. tests/sys/geom/class/gate/ggate_test.sh tests/sys/geom/class/gate/Makefile Add an ATF test with three testcases, one for each TAP test. Use ATF-style cleanup functions, and convert sleeps to polling loops. ObsoleteFiles.inc tests/sys/geom/class/gate/conf.sh tests/sys/geom/class/gate/1_test.sh tests/sys/geom/class/gate/2_test.sh tests/sys/geom/class/gate/3_test.sh Delete TAP test files Reviewed by: ngie MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D8891 r313008: Wait for /dev/ggate* to appear after calling `ggatel create` in :ggatel_{file,md} The test assumed that `ggatel create` created a device on completion, but that's incorrect. This squashes the race by waiting for the device to appear, as `ggatel create` daemonizes before issuing an ioctl to geom_gate(4) if not called with `-v`. Discussed with: asomers MFC after: 1 week PR: 204616 Sponsored by: Dell EMC Isilon r313081: Replace for/retry loops with "wait_for_ggate_device" calls and check results of commands As noted in r313008, the underlying issue was that geom_gate device creation wasn't created at ggatel command completion, but some short time after. ggatec(8) employs similar logic when creating geom_gate(4) devices. Switch from retry loops (after the ggatec/dd write calls) to wait_for_ggate_device function calls after calling ggatec(8) instead to detect the presence of the /dev/ggate* device, as this function is sufficient for determining whether or not the character device is ready for testing While here, use atf_check consistently with all dd calls to ensure that data output is as expected. MFC after: 1 week Reviewed by: asomers Differential Revision: D9409 Sponsored by: Dell EMC Isilon --- ObsoleteFiles.inc | 5 + tests/sys/geom/class/gate/1_test.sh | 63 ---------- tests/sys/geom/class/gate/2_test.sh | 48 -------- tests/sys/geom/class/gate/3_test.sh | 49 -------- tests/sys/geom/class/gate/Makefile | 12 +- tests/sys/geom/class/gate/conf.sh | 8 -- tests/sys/geom/class/gate/ggate_test.sh | 207 ++++++++++++++++++++++++++++++++ 7 files changed, 213 insertions(+), 179 deletions(-) delete mode 100644 tests/sys/geom/class/gate/1_test.sh delete mode 100644 tests/sys/geom/class/gate/2_test.sh delete mode 100644 tests/sys/geom/class/gate/3_test.sh delete mode 100755 tests/sys/geom/class/gate/conf.sh create mode 100755 tests/sys/geom/class/gate/ggate_test.sh diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index cca3c71..addb518 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -38,6 +38,11 @@ # xargs -n1 | sort | uniq -d; # done +# 20170214: Four files from ggate tests consolidated into one +OLD_FILES+=usr/tests/sys/geom/class/gate/1_test +OLD_FILES+=usr/tests/sys/geom/class/gate/2_test +OLD_FILES+=usr/tests/sys/geom/class/gate/3_test +OLD_FILES+=usr/tests/sys/geom/class/gate/conf.sh # 20170211: libarchive ACL pax test renamed to test_acl_pax_posix1e.tar.uu OLD_FILES+=usr/tests/lib/libarchive/test_acl_pax.tar.uu # 20161229: Three files from gnop tests consolidated into one diff --git a/tests/sys/geom/class/gate/1_test.sh b/tests/sys/geom/class/gate/1_test.sh deleted file mode 100644 index ba573bb..0000000 --- a/tests/sys/geom/class/gate/1_test.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -. `dirname $0`/conf.sh - -echo '1..2' - -base=`basename $0` -us=0 -while [ -c /dev/ggate${us} ]; do - : $(( us += 1 )) -done -pidfile=ggated.$$.pid -conf=`mktemp $base.XXXXXX` || exit 1 -port=33080 - -work=$(attach_md -t malloc -s 1M) -src=$(attach_md -t malloc -s 1M) - -test_cleanup() -{ - ggatec destroy -f -u $us - pkill -F $pidfile - geom_test_cleanup -} -trap test_cleanup ABRT EXIT INT TERM - -dd if=/dev/random of=/dev/$work bs=1m count=1 conv=sync -dd if=/dev/random of=/dev/$src bs=1m count=1 conv=sync -src_checksum=$(md5 -q /dev/$src) - -echo "127.0.0.1 RW /dev/$work" > $conf - -if ! ggated -p $port -F $pidfile $conf; then - echo 'ggated failed to start' - echo 'Bail out!' - exit 1 -fi -sleep 1 -if ! ggatec create -p $port -u $us 127.0.0.1 /dev/$work; then - echo 'ggatec create failed' - echo 'Bail out!' - exit 1 -fi -sleep 1 - -dd if=/dev/${src} of=/dev/ggate${us} bs=1m count=1 -sleep 1 - -work_checksum=$(md5 -q /dev/$work) -if [ "$work_checksum" != "$src_checksum" ]; then - echo "not ok 1 - md5 checksums didn't match ($work_checksum != $src_checksum)" - echo "not ok 2 # SKIP" -else - echo 'ok 1 - md5 checksum' - - ggate_checksum=$(md5 -q /dev/ggate${us}) - if [ "$ggate_checksum" != "$src_checksum" ]; then - echo "not ok 2 - md5 checksums didn't match ($ggate_checksum != $src_checksum)" - else - echo 'ok 2 - md5 checksum' - fi -fi diff --git a/tests/sys/geom/class/gate/2_test.sh b/tests/sys/geom/class/gate/2_test.sh deleted file mode 100644 index be89acc..0000000 --- a/tests/sys/geom/class/gate/2_test.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -. `dirname $0`/conf.sh - -base=`basename $0` -us=46 -work=`mktemp -u $base.XXXXXX` || exit 1 -src=`mktemp -u $base.XXXXXX` || exit 1 - -test_cleanup() -{ - ggatel destroy -f -u $us - rm -f $work $src - - geom_test_cleanup -} -trap test_cleanup ABRT EXIT INT TERM - -dd if=/dev/random of=$work bs=1m count=1 conv=sync -dd if=/dev/random of=$src bs=1m count=1 conv=sync - -if ! ggatel create -u $us $work; then - echo 'ggatel create failed' - echo 'Bail out!' - exit 1 -fi - -dd if=${src} of=/dev/ggate${us} bs=1m count=1 -sleep 1 - -echo '1..2' - -src_checksum=$(md5 -q $src) -work_checksum=$(md5 -q $work) -if [ "$work_checksum" != "$src_checksum" ]; then - echo "not ok 1 - md5 checksums didn't match ($work_checksum != $src_checksum) # TODO: bug 204616" - echo 'not ok 2 # SKIP' -else - echo 'ok 1 - md5 checksum' - - ggate_checksum=$(md5 -q /dev/ggate${us}) - if [ "$ggate_checksum" != "$src_checksum" ]; then - echo "not ok 2 - md5 checksums didn't match ($ggate_checksum != $src_checksum)" - else - echo 'ok 2 - md5 checksum' - fi -fi diff --git a/tests/sys/geom/class/gate/3_test.sh b/tests/sys/geom/class/gate/3_test.sh deleted file mode 100644 index 3511df7..0000000 --- a/tests/sys/geom/class/gate/3_test.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -. `dirname $0`/conf.sh - -base=`basename $0` -us=47 - -test_cleanup() -{ - ggatel destroy -f -u $us - - geom_test_cleanup -} -trap test_cleanup ABRT EXIT INT TERM - -work=$(attach_md -t malloc -s 1M) -src=$(attach_md -t malloc -s 1M) - -dd if=/dev/random of=/dev/$work bs=1m count=1 conv=sync -dd if=/dev/random of=/dev/$src bs=1m count=1 conv=sync -src_checksum=$(md5 -q /dev/$src) - -if ! ggatel create -u $us /dev/$work; then - echo 'ggatel create failed' - echo 'Bail out!' - exit 1 -fi - -sleep 1 -dd if=/dev/${src} of=/dev/ggate${us} bs=1m count=1 conv=sync -sleep 1 - -echo '1..2' - -work_checksum=$(md5 -q /dev/$work) -if [ "$work_checksum" != "$src_checksum" ]; then - echo "not ok 1 - md5 checksums didn't match ($work_checksum != $src_checksum)" - echo 'not ok 2 # SKIP' -else - echo 'ok 1 - md5 checksum' - - ggate_checksum=$(md5 -q /dev/ggate${us}) - if [ "$ggate_checksum" != "$src_checksum" ]; then - echo "not ok 2 - md5 checksums didn't match ($ggate_checksum != $src_checksum)" - else - echo 'ok 2 - md5 checksum' - fi -fi diff --git a/tests/sys/geom/class/gate/Makefile b/tests/sys/geom/class/gate/Makefile index 11ceb94..0b84248 100644 --- a/tests/sys/geom/class/gate/Makefile +++ b/tests/sys/geom/class/gate/Makefile @@ -2,16 +2,6 @@ TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T} -TAP_TESTS_SH+= 1_test -TAP_TESTS_SH+= 2_test -TAP_TESTS_SH+= 3_test - -FILES+= conf.sh -FILESNAME_conf.sh= conf.sh -FILESDIR= ${TESTSDIR} - -.for t in ${TAP_TESTS_SH} -TEST_METADATA.$t+= required_user="root" -.endfor +ATF_TESTS_SH+= ggate_test .include diff --git a/tests/sys/geom/class/gate/conf.sh b/tests/sys/geom/class/gate/conf.sh deleted file mode 100755 index 7e22ce4..0000000 --- a/tests/sys/geom/class/gate/conf.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -name="$(mktemp -u gate.XXXXXX)" -class="gate" -base=`basename $0` - -. `dirname $0`/../geom_subr.sh diff --git a/tests/sys/geom/class/gate/ggate_test.sh b/tests/sys/geom/class/gate/ggate_test.sh new file mode 100755 index 0000000..18b4214 --- /dev/null +++ b/tests/sys/geom/class/gate/ggate_test.sh @@ -0,0 +1,207 @@ +# $FreeBSD$ + +PIDFILE=ggated.pid +PLAINFILES=plainfiles +PORT=33080 +CONF=gg.exports + +atf_test_case ggated cleanup +ggated_head() +{ + atf_set "descr" "ggated can proxy geoms" + atf_set "require.progs" "ggatec ggated" + atf_set "require.user" "root" + atf_set "timeout" 60 +} + +ggated_body() +{ + us=$(alloc_ggate_dev) + work=$(alloc_md) + src=$(alloc_md) + + atf_check -e ignore -o ignore \ + dd if=/dev/random of=/dev/$work bs=1m count=1 conv=notrunc + atf_check -e ignore -o ignore \ + dd if=/dev/random of=/dev/$src bs=1m count=1 conv=notrunc + + echo $CONF >> $PLAINFILES + echo "127.0.0.1 RW /dev/$work" > $CONF + + atf_check ggated -p $PORT -F $PIDFILE $CONF + atf_check ggatec create -p $PORT -u $us 127.0.0.1 /dev/$work + + ggate_dev=/dev/ggate${us} + + wait_for_ggate_device ${ggate_dev} + + atf_check -e ignore -o ignore \ + dd if=/dev/${src} of=${ggate_dev} bs=1m count=1 conv=notrunc + + checksum /dev/$src /dev/$work +} + +ggated_cleanup() +{ + common_cleanup +} + +atf_test_case ggatel_file cleanup +ggatel_file_head() +{ + atf_set "descr" "ggatel can proxy files" + atf_set "require.progs" "ggatel" + atf_set "require.user" "root" + atf_set "timeout" 15 +} + +ggatel_file_body() +{ + us=$(alloc_ggate_dev) + + echo src work >> ${PLAINFILES} + dd if=/dev/random of=work bs=1m count=1 + dd if=/dev/random of=src bs=1m count=1 + + atf_check ggatel create -u $us work + + ggate_dev=/dev/ggate${us} + + wait_for_ggate_device ${ggate_dev} + + atf_check -e ignore -o ignore \ + dd if=src of=${ggate_dev} bs=1m count=1 conv=notrunc + + checksum src work +} + +ggatel_file_cleanup() +{ + common_cleanup +} + +atf_test_case ggatel_md cleanup +ggatel_md_head() +{ + atf_set "descr" "ggatel can proxy files" + atf_set "require.progs" "ggatel" + atf_set "require.user" "root" + atf_set "timeout" 15 +} + +ggatel_md_body() +{ + us=$(alloc_ggate_dev) + work=$(alloc_md) + src=$(alloc_md) + + atf_check -e ignore -o ignore \ + dd if=/dev/random of=$work bs=1m count=1 conv=notrunc + atf_check -e ignore -o ignore \ + dd if=/dev/random of=$src bs=1m count=1 conv=notrunc + + atf_check ggatel create -u $us /dev/$work + + ggate_dev=/dev/ggate${us} + + wait_for_ggate_device ${ggate_dev} + + atf_check -e ignore -o ignore \ + dd if=/dev/$src of=${ggate_dev} bs=1m count=1 conv=notrunc + + checksum /dev/$src /dev/$work +} + +ggatel_md_cleanup() +{ + common_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case ggated + atf_add_test_case ggatel_file + atf_add_test_case ggatel_md +} + +alloc_ggate_dev() +{ + local us + + us=0 + while [ -c /dev/ggate${us} ]; do + : $(( us += 1 )) + done + echo ${us} > ggate.devs + echo ${us} +} + +alloc_md() +{ + local md + + md=$(mdconfig -a -t malloc -s 1M) || \ + atf_fail "failed to allocate md device" + echo ${md} >> md.devs + echo ${md} +} + +checksum() +{ + local src work + src=$1 + work=$2 + + src_checksum=$(dd if=${src} bs=1m | md5 -q) + work_checksum=$(dd if=${work} bs=1m | md5 -q) + + if [ "$work_checksum" != "$src_checksum" ]; then + atf_fail "work md5 checksum didn't match" + fi + + ggate_checksum=$(dd if=/dev/ggate${us} bs=1m | md5 -q) + if [ "$ggate_checksum" != "$src_checksum" ]; then + atf_fail "ggate md5 checksum didn't match" + fi +} + +common_cleanup() +{ + if [ -f "ggate.devs" ]; then + while read test_ggate; do + ggatec destroy -f -u $test_ggate >/dev/null + done < ggate.devs + rm ggate.devs + fi + + if [ -f "$PIDFILE" ]; then + pkill -F "$PIDFILE" + rm $PIDFILE + fi + + if [ -f "PLAINFILES" ]; then + while read f; do + rm -f ${f} + done < ${PLAINFILES} + rm ${PLAINFILES} + fi + + if [ -f "md.devs" ]; then + while read test_md; do + mdconfig -d -u $test_md 2>/dev/null + done < md.devs + rm md.devs + fi + true +} + +# Bug 204616: ggatel(8) creates /dev/ggate* asynchronously if `ggatel create` +# isn't called with `-v`. +wait_for_ggate_device() +{ + ggate_device=$1 + + while [ ! -c $ggate_device ]; do + sleep 0.5 + done +} -- cgit v1.1 From d879ecc52f6343cc917540c31fb045d28d786432 Mon Sep 17 00:00:00 2001 From: garga Date: Wed, 15 Feb 2017 09:15:51 +0000 Subject: MFC r313448: bsdinstall: Make sure chroot filesystems are umounted after use * DISTDIR_IS_UNIONFS is set every time BSDINSTALL_DISTDIR is mounted inside BSDINSTALL_CHROOT. Use this flag to decide if it needs to be umounted * BSDINSTALL_CHROOT/dev is mounted when 'bsdinstall mount' is called, there is no need to mount it again when user goes to shell after installation Reviewed by: allanjude Obtained from: pfSense MFC after: 1 week Sponsored by: Rubicon Communications (Netgate) Differential Revision: https://reviews.freebsd.org/D8573 --- usr.sbin/bsdinstall/scripts/auto | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto index b7ce48b..fd88c84 100755 --- a/usr.sbin/bsdinstall/scripts/auto +++ b/usr.sbin/bsdinstall/scripts/auto @@ -387,9 +387,11 @@ finalconfig trap error SIGINT # SIGINT is bad again bsdinstall config || error "Failed to save config" +if [ -n "$DISTDIR_IS_UNIONFS" ]; then + umount -f $BSDINSTALL_DISTDIR +fi + if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then - [ "$BSDINSTALL_FETCHDEST" != "$BSDINSTALL_DISTDIR" ] && \ - umount "$BSDINSTALL_DISTDIR" rm -rf "$BSDINSTALL_FETCHDEST" fi @@ -398,7 +400,6 @@ dialog --backtitle "FreeBSD Installer" --title "Manual Configuration" \ "The installation is now finished. Before exiting the installer, would you like to open a shell in the new system to make any final manual modifications?" 0 0 if [ $? -eq 0 ]; then clear - mount -t devfs devfs "$BSDINSTALL_CHROOT/dev" echo This shell is operating in a chroot in the new system. \ When finished making configuration changes, type \"exit\". chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1 -- cgit v1.1 From a1f47ea5384ed91ee4f80402eb3740b103b594c9 Mon Sep 17 00:00:00 2001 From: garga Date: Wed, 15 Feb 2017 09:18:08 +0000 Subject: MFC r313457: Fix style(9) Reviewed by: vangyzen, allanjude, cem Approved by: allanjude MFC after: 1 week Sponsored by: Rubicon Communications (Netgate) Differential Revision: https://reviews.freebsd.org/D9494 --- usr.sbin/arp/arp.c | 90 ++++++++++++++++++++++++++---------------------------- 1 file changed, 44 insertions(+), 46 deletions(-) diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c index eefde75..2783b88 100644 --- a/usr.sbin/arp/arp.c +++ b/usr.sbin/arp/arp.c @@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$"); * arp - display, set, and delete arp table entries */ - #include #include #include @@ -80,8 +79,8 @@ __FBSDID("$FreeBSD$"); #include #include -typedef void (action_fn)(struct sockaddr_dl *sdl, - struct sockaddr_in *s_in, struct rt_msghdr *rtm); +typedef void (action_fn)(struct sockaddr_dl *sdl, struct sockaddr_in *s_in, + struct rt_msghdr *rtm); static int search(u_long addr, action_fn *action); static action_fn print_entry; @@ -344,18 +343,20 @@ set(int argc, char **argv) } } else if (strncmp(argv[0], "blackhole", 9) == 0) { if (flags & RTF_REJECT) { - printf("Choose one of blackhole or reject, not both.\n"); + printf("Choose one of blackhole or reject, " + "not both."); } flags |= RTF_BLACKHOLE; } else if (strncmp(argv[0], "reject", 6) == 0) { if (flags & RTF_BLACKHOLE) { - printf("Choose one of blackhole or reject, not both.\n"); + printf("Choose one of blackhole or reject, " + "not both."); } flags |= RTF_REJECT; } else if (strncmp(argv[0], "trail", 5) == 0) { /* XXX deprecated and undocumented feature */ printf("%s: Sending trailers is no longer supported\n", - host); + host); } argv++; } @@ -381,7 +382,7 @@ set(int argc, char **argv) /* * In the case a proxy-arp entry is being added for - * a remote end point, the RTF_ANNOUNCE flag in the + * a remote end point, the RTF_ANNOUNCE flag in the * RTM_GET command is an indication to the kernel * routing code that the interface associated with * the prefix route covering the local end of the @@ -467,7 +468,7 @@ delete(char *host) sdl = (struct sockaddr_dl *)(SA_SIZE(addr) + (char *)addr); /* - * With the new L2/L3 restructure, the route + * With the new L2/L3 restructure, the route * returned is a prefix route. The important * piece of information from the previous * RTM_GET is the interface index. In the @@ -486,7 +487,7 @@ delete(char *host) * is a proxy-arp entry to remove. */ if (flags & RTF_ANNOUNCE) { - fprintf(stderr, "delete: cannot locate %s\n",host); + fprintf(stderr, "delete: cannot locate %s\n", host); return (1); } @@ -525,7 +526,7 @@ search(u_long addr, action_fn *action) mib[5] = RTF_LLINFO; #else mib[5] = 0; -#endif +#endif if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) err(1, "route-sysctl-estimate"); if (needed == 0) /* empty table */ @@ -575,7 +576,7 @@ print_entry(struct sockaddr_dl *sdl, struct if_nameindex *p; int seg; - if (ifnameindex == NULL) + if (ifnameindex == NULL) if ((ifnameindex = if_nameindex()) == NULL) err(1, "cannot retrieve interface names"); @@ -597,7 +598,8 @@ print_entry(struct sockaddr_dl *sdl, sdl->sdl_type == IFT_L2VLAN || sdl->sdl_type == IFT_BRIDGE) && sdl->sdl_alen == ETHER_ADDR_LEN) - printf("%s", ether_ntoa((struct ether_addr *)LLADDR(sdl))); + printf("%s", + ether_ntoa((struct ether_addr *)LLADDR(sdl))); else { int n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0; @@ -607,7 +609,7 @@ print_entry(struct sockaddr_dl *sdl, printf("(incomplete)"); for (p = ifnameindex; p && ifnameindex->if_index && - ifnameindex->if_name; p++) { + ifnameindex->if_name; p++) { if (p->if_index == sdl->sdl_index) { printf(" on %s", p->if_name); break; @@ -629,31 +631,31 @@ print_entry(struct sockaddr_dl *sdl, printf(" published"); switch(sdl->sdl_type) { case IFT_ETHER: - printf(" [ethernet]"); - break; + printf(" [ethernet]"); + break; case IFT_ISO88025: - printf(" [token-ring]"); + printf(" [token-ring]"); trld = SDL_ISO88025(sdl); if (trld->trld_rcf != 0) { printf(" rt=%x", ntohs(trld->trld_rcf)); for (seg = 0; seg < ((TR_RCF_RIFLEN(trld->trld_rcf) - 2 ) / 2); - seg++) + seg++) printf(":%x", ntohs(*(trld->trld_route[seg]))); } break; case IFT_FDDI: - printf(" [fddi]"); - break; + printf(" [fddi]"); + break; case IFT_ATM: - printf(" [atm]"); - break; + printf(" [atm]"); + break; case IFT_L2VLAN: printf(" [vlan]"); break; case IFT_IEEE1394: - printf(" [firewire]"); - break; + printf(" [firewire]"); + break; case IFT_BRIDGE: printf(" [bridge]"); break; @@ -662,8 +664,8 @@ print_entry(struct sockaddr_dl *sdl, break; default: break; - } - + } + printf("\n"); } @@ -688,13 +690,13 @@ static void usage(void) { fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n", - "usage: arp [-n] [-i interface] hostname", - " arp [-n] [-i interface] -a", - " arp -d hostname [pub]", - " arp -d [-i interface] -a", - " arp -s hostname ether_addr [temp] [reject | blackhole] [pub [only]]", - " arp -S hostname ether_addr [temp] [reject | blackhole] [pub [only]]", - " arp -f filename"); + "usage: arp [-n] [-i interface] hostname", + " arp [-n] [-i interface] -a", + " arp -d hostname [pub]", + " arp -d [-i interface] -a", + " arp -s hostname ether_addr [temp] [reject | blackhole] [pub [only]]", + " arp -S hostname ether_addr [temp] [reject | blackhole] [pub [only]]", + " arp -f filename"); exit(1); } @@ -753,12 +755,12 @@ rtmsg(int cmd, struct sockaddr_in *dst, struct sockaddr_dl *sdl) case RTM_GET: rtm->rtm_addrs |= RTA_DST; } -#define NEXTADDR(w, s) \ - do { \ - if ((s) != NULL && rtm->rtm_addrs & (w)) { \ - bcopy((s), cp, sizeof(*(s))); \ - cp += SA_SIZE(s); \ - } \ +#define NEXTADDR(w, s) \ + do { \ + if ((s) != NULL && rtm->rtm_addrs & (w)) { \ + bcopy((s), cp, sizeof(*(s))); \ + cp += SA_SIZE(s); \ + } \ } while (0) NEXTADDR(RTA_DST, dst); @@ -814,7 +816,7 @@ get_ether_addr(in_addr_t ipaddr, struct ether_addr *hwaddr) } #define NEXTIFR(i) \ - ((struct ifreq *)((char *)&(i)->ifr_addr \ + ((struct ifreq *)((char *)&(i)->ifr_addr \ + MAX((i)->ifr_addr.sa_len, sizeof((i)->ifr_addr))) ) /* @@ -835,14 +837,10 @@ get_ether_addr(in_addr_t ipaddr, struct ether_addr *hwaddr) if (ioctl(sock, SIOCGIFFLAGS, &ifreq) < 0) continue; if ((ifreq.ifr_flags & - (IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT| - IFF_LOOPBACK|IFF_NOARP)) - != (IFF_UP|IFF_BROADCAST)) + (IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT| + IFF_LOOPBACK|IFF_NOARP)) != (IFF_UP|IFF_BROADCAST)) continue; - /* - * Get its netmask and check that it's on - * the right subnet. - */ + /* Get its netmask and check that it's on the right subnet. */ if (ioctl(sock, SIOCGIFNETMASK, &ifreq) < 0) continue; mask = ((struct sockaddr_in *) -- cgit v1.1 From 9a0f095e80b414dfa86c07ac17998b455cc982e8 Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 16 Feb 2017 04:23:45 +0000 Subject: MFC r288241: r288241 (by bdrewery): Remove 'set -e' that are no longer needed as it is already default. When bmake was initially imported at r241298 shell commands were no longer ran with 'set -e' as they were before. This was fixed in r254980 so they again always use 'set -e'. --- share/mk/bsd.subdir.mk | 7 +++---- share/mk/suite.test.mk | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/share/mk/bsd.subdir.mk b/share/mk/bsd.subdir.mk index 9d2eb17..84382e3 100644 --- a/share/mk/bsd.subdir.mk +++ b/share/mk/bsd.subdir.mk @@ -45,7 +45,7 @@ distribute: .MAKE _SUBDIR: .USE .MAKE .if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR) - @${_+_}set -e; for entry in ${SUBDIR:N.WAIT}; do \ + @${_+_}for entry in ${SUBDIR:N.WAIT}; do \ if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \ ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH} (${.TARGET:S,realinstall,install,:S,^_sub.,,})"; \ edir=$${entry}.${MACHINE_ARCH}; \ @@ -86,8 +86,7 @@ __deps+= ${__target}_subdir_${__dep} .endfor ${__target}_subdir_${__dir}: .PHONY .MAKE ${__deps} .if !defined(NO_SUBDIR) - @${_+_}set -e; \ - if test -d ${.CURDIR}/${__dir}.${MACHINE_ARCH}; then \ + @${_+_}if test -d ${.CURDIR}/${__dir}.${MACHINE_ARCH}; then \ ${ECHODIR} "===> ${DIRPRFX}${__dir}.${MACHINE_ARCH} (${__target:realinstall=install})"; \ edir=${__dir}.${MACHINE_ARCH}; \ cd ${.CURDIR}/$${edir}; \ @@ -118,7 +117,7 @@ _sub.${__stage}${__target}: _SUBDIR .endfor .if !target(${__target}) ${__target}: .MAKE - ${_+_}set -e; cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target} + ${_+_}cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target} .endif .endfor diff --git a/share/mk/suite.test.mk b/share/mk/suite.test.mk index 0d48950..7061261 100644 --- a/share/mk/suite.test.mk +++ b/share/mk/suite.test.mk @@ -90,8 +90,7 @@ realtest: .PHONY @echo "*** installed in ${TESTSBASE}. This test run may raise false" @echo "*** positives and/or false negatives." @echo - @set -e; \ - ${KYUA} test -k ${DESTDIR}${TESTSDIR}/Kyuafile; \ + @${KYUA} test -k ${DESTDIR}${TESTSDIR}/Kyuafile; \ result=0; \ echo; \ echo "*** Once again, note that "make test" is unsupported."; \ -- cgit v1.1 From 4375a855a9ebfec903c6ee076c8aa62401e43ffc Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 16 Feb 2017 05:14:07 +0000 Subject: MFC r285119,r292502,r295380: r285119 (by jmmv): Add support for TEST_METADATA Allow Makefiles to define generic metadata settings that apply to all test programs defined by a Makefile. The generic TEST_METADATA variable extends the per-test program settings already supported via TEST_METADATA.. This feature will be useful to easily apply some settings to all programs in a directory. In particular, Kyua 0.12 will support parallel execution of test programs and a bunch of them will need to be tagged as is_exclusive to indicate that they cannot be run in parallel with anything else due to their side-effects. It will be reasonable to set this setting on whole directories. r292502: Always expose LOCALBASE, not just when CROSS_TOOLCHAIN is defined Instead of using which(1) to look for doxygen, look for it in /bin . $PATH gets mangled by make buildenv, etc so it's better to just be explicit about the path if someone uses that for instance. r295380: Simplify running the FreeBSD test suite Replace `make regress` (legacy test make target) and `make test` (incomplete test make target added with the FreeBSD test suite) with make check as it's consistent with other open source projects. `make check` defaults to running tests from `.OBJDIR`, but can be overridden with the `CHECKDIR` variable. Add `make checkworld` target to simplify running the FreeBSD test suite from `TESTSBASE` (i.e. the top-level tests directory), similar to buildworld. Document `make check` and `make checkworld` in build(7). Other minor changes: - Rename intermediate file (`Kyuafile.auto`) to `Kyuafile` to simplify `make check`. - Remove terse warnings attached to `beforetest`/`aftertest`. - Add kyua binary check to check target in suite.test.mk; error out if it's not found The MFC is [partly] contingent on other build related changes being MFCed. X-MFC to: stable/10 Relnotes: yes --- Makefile | 11 ++++++-- Makefile.inc1 | 19 ++++++++++++- share/man/man7/build.7 | 13 ++++++++- share/mk/bsd.README | 21 ++++++++++---- share/mk/bsd.subdir.mk | 8 +++--- share/mk/bsd.sys.mk | 4 +-- share/mk/bsd.test.mk | 19 ++++++------- share/mk/suite.test.mk | 74 ++++++++++++++++++++++---------------------------- 8 files changed, 100 insertions(+), 69 deletions(-) diff --git a/Makefile b/Makefile index 3953bd4..a77f1ae 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,7 @@ # kernel-toolchains - Build kernel-toolchain for all universe targets. # doxygen - Build API documentation of the kernel, needs doxygen. # update - Convenient way to update your source tree(s). +# checkworld - Run test suite on installed world. # check-old - List obsolete directories/files/libraries. # check-old-dirs - List obsolete directories. # check-old-files - List obsolete files. @@ -99,8 +100,8 @@ # For more information, see the build(7) manual page. # TGTS= all all-man buildenv buildenvvars buildkernel buildworld \ - check-old check-old-dirs check-old-files check-old-libs \ - checkdpadd clean cleandepend cleandir \ + check check-old check-old-dirs check-old-files check-old-libs \ + checkdpadd checkworld clean cleandepend cleandir \ delete-old delete-old-dirs delete-old-files delete-old-libs \ depend distribute distributekernel distributekernel.debug \ distributeworld distrib-dirs distribution doxygen \ @@ -108,7 +109,7 @@ TGTS= all all-man buildenv buildenvvars buildkernel buildworld \ installkernel.debug packagekernel packageworld \ reinstallkernel reinstallkernel.debug \ installworld kernel-toolchain libraries lint maninstall \ - obj objlink regress rerelease showconfig tags toolchain update \ + obj objlink rerelease showconfig tags toolchain update \ _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ _build-tools _cross-tools _includes _libraries _depend \ build32 builddtb distribute32 install32 xdev xdev-build xdev-install \ @@ -374,6 +375,10 @@ make bmake: .PHONY ${MMAKE} all; \ ${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR= +regress: .PHONY + @echo "'make regress' has been renamed 'make check'" | /usr/bin/fmt + @false + tinderbox toolchains kernel-toolchains: upgrade_checks tinderbox: diff --git a/Makefile.inc1 b/Makefile.inc1 index 592ab34..4593536 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -35,6 +35,7 @@ # The intended user-driven targets are: # buildworld - rebuild *everything*, including glue to help do upgrades # installworld- install everything built by "buildworld" +# checkworld - run test suite on installed world # doxygen - build API documentation of the kernel # update - convenient way to update your source tree (eg: svn/svnup) # @@ -50,6 +51,8 @@ .include .include +LOCALBASE?= /usr/local + # We must do share/info early so that installation of info `dir' # entries works correctly. Do it first since it is less likely to # grow dependencies on include and lib than vice versa. @@ -1190,12 +1193,26 @@ packagekernel: .endif # +# +# checkworld +# +# Run test suite on installed world. +# +checkworld: .PHONY + @if [ ! -x ${LOCALBASE}/bin/kyua ]; then \ + echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \ + exit 1; \ + fi + ${_+_}${LOCALBASE}/bin/kyua test -k ${TESTSBASE}/Kyuafile + +# +# # doxygen # # Build the API documentation with doxygen # doxygen: .PHONY - @if [ ! -x `/usr/bin/which doxygen` ]; then \ + @if [ ! -x ${LOCALBASE}/bin/doxygen ]; then \ echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \ exit 1; \ fi diff --git a/share/man/man7/build.7 b/share/man/man7/build.7 index 912d146..d405e17 100644 --- a/share/man/man7/build.7 +++ b/share/man/man7/build.7 @@ -107,6 +107,16 @@ section below, and by the variables documented in The following list provides the names and actions for the targets supported by the build system: .Bl -tag -width ".Cm cleandepend" +.It Cm check +Run tests for a given subdirectory. +The default directory used is +.Pa ${.OBJDIR} , +but the check directory can be changed with +.Pa ${CHECKDIR} . +.It Cm checkworld +Run the +.Fx +test suite on installed world. .It Cm clean Remove any files created during the build process. .It Cm cleandepend @@ -653,6 +663,7 @@ make TARGET=sparc64 DESTDIR=/clients/sparc64 installworld .Xr mergemaster 8 , .Xr portsnap 8 , .Xr reboot 8 , -.Xr shutdown 8 +.Xr shutdown 8 , +.Xr tests 7 .Sh AUTHORS .An Mike W. Meyer Aq mwm@mired.org . diff --git a/share/mk/bsd.README b/share/mk/bsd.README index ea46202..6ec9716 100644 --- a/share/mk/bsd.README +++ b/share/mk/bsd.README @@ -492,6 +492,17 @@ It has seven targets: all: build the test programs. + check: + runs the test programs from CHECKDIR with kyua test. + + The beforecheck and aftercheck targets will be invoked, if + defined, to execute commands before and after the realcheck + target has been executed, respectively. + + The devel/kyua package must be installed before invoking this + target. + + See CHECKDIR for more details. clean: remove the test programs and any object files. cleandir: @@ -510,12 +521,6 @@ It has seven targets: run lint on the source files. tags: create a tags file for the source files. - test: - runs the test programs from the object directory; if the - Makefile does not itself define the target test, the - targets beforetest and aftertest may also be used to - cause actions immediately before and after the test - target is executed. It sets/uses the following variables, among many others: @@ -529,6 +534,10 @@ TESTSDIR Path to the installed tests. Must be a subdirectory of ${TESTSBASE}/${RELDIR:H} , e.g. /usr/tests/bin/ls when included from bin/ls/tests . +CHECKDIR The directory that 'make check' executes tests from. + + The value of CHECKDIR defaults to .OBJDIR. + KYUAFILE If 'auto' (the default), generate a Kyuafile out of the test programs defined in the Makefile. If 'yes', then a manually-crafted Kyuafile must be supplied with the diff --git a/share/mk/bsd.subdir.mk b/share/mk/bsd.subdir.mk index 84382e3..82ff2e3 100644 --- a/share/mk/bsd.subdir.mk +++ b/share/mk/bsd.subdir.mk @@ -24,9 +24,9 @@ # This is a variant of install, which will # put the stuff into the right "distribution". # -# afterinstall, all, all-man, beforeinstall, checkdpadd, clean, +# afterinstall, all, all-man, beforeinstall, check, checkdpadd, clean, # cleandepend, cleandir, cleanilinks depend, install, lint, -# maninstall, manlint, obj, objlink, realinstall, regress, tags +# maninstall, manlint, obj, objlink, realinstall, tags # .if !target(____) @@ -70,9 +70,9 @@ ${SUBDIR:N.WAIT}: .PHONY .MAKE # Work around parsing of .if nested in .for by putting .WAIT string into a var. __wait= .WAIT -.for __target in all all-man checkdpadd clean cleandepend cleandir \ +.for __target in all all-man check checkdpadd clean cleandepend cleandir \ cleanilinks depend distribute lint maninstall manlint obj objlink \ - realinstall regress tags ${SUBDIR_TARGETS} + realinstall tags ${SUBDIR_TARGETS} .ifdef SUBDIR_PARALLEL __subdir_targets= .for __dir in ${SUBDIR} diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index b36e1ba..6a2db01 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -158,11 +158,11 @@ CFLAGS+= ${CWARNFLAGS} ${CWARNFLAGS.${.IMPSRC:T}} # or expect to ever be up-to-date. PHONY_NOTMAIN = afterdepend afterinstall all beforedepend beforeinstall \ beforelinking build build-tools buildfiles buildincludes \ - checkdpadd clean cleandepend cleandir cleanobj configure \ + check checkdpadd clean cleandepend cleandir cleanobj configure \ depend dependall distclean distribute exe extract \ html includes install installfiles installincludes lint \ obj objlink objs objwarn realall realdepend \ - realinstall regress subdir-all subdir-depend subdir-install \ + realinstall subdir-all subdir-depend subdir-install \ tags whereobj .if defined(PORTNAME) diff --git a/share/mk/bsd.test.mk b/share/mk/bsd.test.mk index 0809803..24c9714 100644 --- a/share/mk/bsd.test.mk +++ b/share/mk/bsd.test.mk @@ -68,11 +68,15 @@ _TESTS= .include .include +# kyua automatically descends directories; only run make check on the +# top-level directory +.if !make(check) .for ts in ${TESTS_SUBDIRS} .if empty(SUBDIR:M${ts}) SUBDIR+= ${ts} .endif .endfor +.endif # it is rare for test cases to have man pages .if !defined(MAN) @@ -83,18 +87,13 @@ MAN= .include .endif -.if !target(realtest) -realtest: .PHONY +.if !target(realcheck) +realcheck: .PHONY @echo "$@ not defined; skipping" .endif -test: .PHONY -.ORDER: beforetest realtest -test: beforetest realtest - -.if target(aftertest) -.ORDER: realtest aftertest -test: aftertest -.endif +beforecheck realcheck aftercheck check: .PHONY +.ORDER: beforecheck realcheck aftercheck +check: beforecheck realcheck aftercheck .include diff --git a/share/mk/suite.test.mk b/share/mk/suite.test.mk index 7061261..11f4911 100644 --- a/share/mk/suite.test.mk +++ b/share/mk/suite.test.mk @@ -30,12 +30,19 @@ KYUAFILE?= auto # Kyua as this is later encoded in the Kyuafile test program definitions. #TEST_INTERFACE.= interface-name +# Metadata properties applicable to all test programs. +# +# All the variables for a test program defined in the Makefile are appended +# to the test program's definition in the Kyuafile. This feature can be +# used to avoid having to explicitly supply a Kyuafile in the source +# directory, allowing the caller Makefile to rely on the KYUAFILE=auto +# behavior defined here. +#TEST_METADATA+= key="value" + # Per-test program metadata properties as a list of key/value pairs. # -# All the variables for a particular program are appended to the program's -# definition in the Kyuafile. This feature can be used to avoid having to -# explicitly supply a Kyuafile in the source directory, allowing the caller -# Makefile to rely on the KYUAFILE=auto behavior defined here. +# These per-test program settings _extend_ the values provided in the +# unqualified TEST_METADATA variable. #TEST_METADATA.+= key="value" .if ${KYUAFILE:tl} != "no" @@ -43,11 +50,12 @@ FILES+= Kyuafile FILESDIR_Kyuafile= ${TESTSDIR} .endif -.if ${KYUAFILE:tl} == "auto" -CLEANFILES+= Kyuafile Kyuafile.tmp -.endif +.for _T in ${_TESTS} +_TEST_METADATA.${_T}= ${TEST_METADATA} ${TEST_METADATA.${_T}} +.endfor .if ${KYUAFILE:tl} == "auto" +CLEANFILES+= Kyuafile Kyuafile.tmp Kyuafile: Makefile @{ \ echo '-- Automatically generated by bsd.test.mk.'; \ @@ -59,10 +67,10 @@ Kyuafile: Makefile } > ${.TARGET}.tmp .for _T in ${_TESTS} .if defined(.PARSEDIR) - @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \ + @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${_TEST_METADATA.${_T}:C/$/,/:tW:C/^/, /W:C/,$//W}}' \ >>${.TARGET}.tmp .else - @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${TEST_METADATA.${_T}:C/^/, /:Q:S/\\ ,/,/g:S,\\,,g}}' \ + @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${_TEST_METADATA.${_T}:C/^/, /:Q:S/\\ ,/,/g:S,\\,,g}}' \ >>Kyuafile.auto.tmp .endif .endfor @@ -72,9 +80,11 @@ Kyuafile: Makefile @mv ${.TARGET}.tmp ${.TARGET} .endif +CHECKDIR?= ${DESTDIR}${TESTSDIR} + KYUA= ${LOCALBASE}/bin/kyua -.if exists(${KYUA}) -# Definition of the "make test" target and supporting variables. + +# Definition of the "make check" target and supporting variables. # # This target, by necessity, can only work for native builds (i.e. a FreeBSD # host building a release for the same system). The target runs Kyua, which is @@ -83,35 +93,15 @@ KYUA= ${LOCALBASE}/bin/kyua # Due to the dependencies of the binaries built by the source tree and how they # are used by tests, it is highly possible for a execution of "make test" to # report bogus results unless the new binaries are put in place. -realtest: .PHONY - @echo "*** WARNING: make test is experimental" - @echo "***" - @echo "*** Using this test does not preclude you from running the tests" - @echo "*** installed in ${TESTSBASE}. This test run may raise false" - @echo "*** positives and/or false negatives." - @echo - @${KYUA} test -k ${DESTDIR}${TESTSDIR}/Kyuafile; \ - result=0; \ - echo; \ - echo "*** Once again, note that "make test" is unsupported."; \ - test $${result} -eq 0 -.endif -beforetest: .PHONY -.if defined(TESTSDIR) -.if ${TESTSDIR} == ${TESTSBASE} -# Forbid running from ${TESTSBASE}. It can cause false positives/negatives and -# it does not cover all the tests (e.g. it misses testing software in external). - @echo "*** Sorry, you cannot use make test from src/tests. Install the" - @echo "*** tests into their final location and run them from ${TESTSBASE}" - @false -.else - @echo "*** Using this test does not preclude you from running the tests" - @echo "*** installed in ${TESTSBASE}. This test run may raise false" - @echo "*** positives and/or false negatives." -.endif -.else - @echo "*** No TESTSDIR defined; nothing to do." - @false -.endif - @echo +realcheck: .PHONY + @if [ ! -x ${KYUA} ]; then \ + echo; \ + echo "kyua binary not installed at expected location (${.TARGET})"; \ + echo; \ + echo "Please install via pkg install, or specify the path to the kyua"; \ + echo "package via the \$${LOCALBASE} variable, e.g. "; \ + echo "LOCALBASE=\"${LOCALBASE}\""; \ + false; \ + fi + @${KYUA} test -k ${CHECKDIR}/Kyuafile -- cgit v1.1 From c24b3d03cce94f25420879d0872869ee08989f08 Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 16 Feb 2017 05:17:40 +0000 Subject: MFC r295643: r295643 (by bdrewery): Test directories can build in parallel fine. --- bin/sh/tests/Makefile | 2 -- cddl/usr.sbin/dtrace/tests/common/Makefile | 2 -- share/mk/bsd.test.mk | 1 + tests/sys/Makefile | 2 -- tests/sys/pjdfstest/tests/Makefile | 2 -- usr.bin/bmake/tests/Makefile.inc | 3 +++ 6 files changed, 4 insertions(+), 8 deletions(-) create mode 100644 usr.bin/bmake/tests/Makefile.inc diff --git a/bin/sh/tests/Makefile b/bin/sh/tests/Makefile index a9abc80..d93e19a 100644 --- a/bin/sh/tests/Makefile +++ b/bin/sh/tests/Makefile @@ -10,6 +10,4 @@ TESTS_SUBDIRS+= parameters TESTS_SUBDIRS+= parser TESTS_SUBDIRS+= set-e -SUBDIR_PARALLEL= - .include diff --git a/cddl/usr.sbin/dtrace/tests/common/Makefile b/cddl/usr.sbin/dtrace/tests/common/Makefile index 02381c6..7c7bb17 100644 --- a/cddl/usr.sbin/dtrace/tests/common/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/Makefile @@ -86,6 +86,4 @@ TESTS_SUBDIRS+= aggs \ .PATH: ${.CURDIR:H:H:H:H:H}/tests KYUAFILE= YES -SUBDIR_PARALLEL= - .include diff --git a/share/mk/bsd.test.mk b/share/mk/bsd.test.mk index 24c9714..b2c8f91 100644 --- a/share/mk/bsd.test.mk +++ b/share/mk/bsd.test.mk @@ -76,6 +76,7 @@ _TESTS= SUBDIR+= ${ts} .endif .endfor +SUBDIR_PARALLEL= t .endif # it is rare for test cases to have man pages diff --git a/tests/sys/Makefile b/tests/sys/Makefile index c18c387..a11d33e 100644 --- a/tests/sys/Makefile +++ b/tests/sys/Makefile @@ -22,6 +22,4 @@ TESTS_SUBDIRS+= vm # Items not integrated into kyua runs by default SUBDIR+= pjdfstest -SUBDIR_PARALLEL= - .include diff --git a/tests/sys/pjdfstest/tests/Makefile b/tests/sys/pjdfstest/tests/Makefile index 61b15dd..95b4bbe 100644 --- a/tests/sys/pjdfstest/tests/Makefile +++ b/tests/sys/pjdfstest/tests/Makefile @@ -36,6 +36,4 @@ TESTS_SUBDIRS+= symlink TESTS_SUBDIRS+= truncate TESTS_SUBDIRS+= unlink -SUBDIR_PARALLEL= - .include diff --git a/usr.bin/bmake/tests/Makefile.inc b/usr.bin/bmake/tests/Makefile.inc new file mode 100644 index 0000000..b2201e4 --- /dev/null +++ b/usr.bin/bmake/tests/Makefile.inc @@ -0,0 +1,3 @@ +# $FreeBSD$ + +SUBDIR_PARALLEL= t -- cgit v1.1 From e12cc5315e55c22b59efcf2a1af5c171498306a7 Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 16 Feb 2017 05:22:08 +0000 Subject: Fix mismerge in r313790 Use ${.TARGET}, not Kyuafile.auto* for the fmake case This is a direct commit to ^/stable/10 Sponsored by: Dell EMC Isilon --- share/mk/suite.test.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/mk/suite.test.mk b/share/mk/suite.test.mk index 11f4911..90e1687 100644 --- a/share/mk/suite.test.mk +++ b/share/mk/suite.test.mk @@ -71,7 +71,7 @@ Kyuafile: Makefile >>${.TARGET}.tmp .else @echo '${TEST_INTERFACE.${_T}}_test_program{name="${_T}"${_TEST_METADATA.${_T}:C/^/, /:Q:S/\\ ,/,/g:S,\\,,g}}' \ - >>Kyuafile.auto.tmp + >>${.TARGET}.tmp .endif .endfor .for _T in ${TESTS_SUBDIRS:N.WAIT} -- cgit v1.1 From 56a2bc6d18205a3bce7d1b03605bf0683b2dee79 Mon Sep 17 00:00:00 2001 From: kib Date: Thu, 16 Feb 2017 06:00:57 +0000 Subject: MFC r313692: Style: wrap long line. --- sys/compat/freebsd32/freebsd32_misc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index db5e45d..f1ad912 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -598,7 +598,8 @@ freebsd32_mmap(struct thread *td, struct freebsd32_mmap_args *uap) #ifdef COMPAT_FREEBSD6 int -freebsd6_freebsd32_mmap(struct thread *td, struct freebsd6_freebsd32_mmap_args *uap) +freebsd6_freebsd32_mmap(struct thread *td, + struct freebsd6_freebsd32_mmap_args *uap) { struct freebsd32_mmap_args ap; -- cgit v1.1 From 67fb1296dfd5edac0f3daae4774e67c7bc5477c0 Mon Sep 17 00:00:00 2001 From: delphij Date: Thu, 16 Feb 2017 06:16:50 +0000 Subject: MFC r311285,312335: zlib 1.2.11. --- contrib/zlib/ChangeLog | 55 ++- contrib/zlib/README | 6 +- contrib/zlib/adler32.c | 21 +- contrib/zlib/compress.c | 42 +- contrib/zlib/contrib/README.contrib | 4 +- contrib/zlib/crc32.c | 41 +- contrib/zlib/deflate.c | 802 ++++++++++++++++++++++-------------- contrib/zlib/deflate.h | 35 +- contrib/zlib/gzguts.h | 23 +- contrib/zlib/gzlib.c | 31 +- contrib/zlib/gzread.c | 156 ++++--- contrib/zlib/gzwrite.c | 332 +++++++++------ contrib/zlib/infback.c | 4 +- contrib/zlib/inffast.c | 85 ++-- contrib/zlib/inflate.c | 123 ++++-- contrib/zlib/inflate.h | 11 +- contrib/zlib/inftrees.c | 26 +- contrib/zlib/test/example.c | 17 +- contrib/zlib/test/infcover.c | 18 +- contrib/zlib/test/minigzip.c | 12 +- contrib/zlib/trees.c | 99 ++--- contrib/zlib/uncompr.c | 98 +++-- contrib/zlib/zconf.h | 41 +- contrib/zlib/zconf.h.in | 41 +- contrib/zlib/zlib.3 | 72 ++-- contrib/zlib/zlib.h | 452 +++++++++++++------- contrib/zlib/zlib.map | 177 ++++---- contrib/zlib/zutil.c | 49 +-- contrib/zlib/zutil.h | 52 ++- lib/libz/Symbol.map | 11 + lib/libz/Versions.def | 3 + lib/libz/zlib.pc | 2 +- 32 files changed, 1825 insertions(+), 1116 deletions(-) diff --git a/contrib/zlib/ChangeLog b/contrib/zlib/ChangeLog index f22aaba..30199a6 100644 --- a/contrib/zlib/ChangeLog +++ b/contrib/zlib/ChangeLog @@ -1,10 +1,53 @@ ChangeLog file for zlib +Changes in 1.2.11 (15 Jan 2017) +- Fix deflate stored bug when pulling last block from window +- Permit immediate deflateParams changes before any deflate input + +Changes in 1.2.10 (2 Jan 2017) +- Avoid warnings on snprintf() return value +- Fix bug in deflate_stored() for zero-length input +- Fix bug in gzwrite.c that produced corrupt gzip files +- Remove files to be installed before copying them in Makefile.in +- Add warnings when compiling with assembler code + +Changes in 1.2.9 (31 Dec 2016) +- Fix contrib/minizip to permit unzipping with desktop API [Zouzou] +- Improve contrib/blast to return unused bytes +- Assure that gzoffset() is correct when appending +- Improve compress() and uncompress() to support large lengths +- Fix bug in test/example.c where error code not saved +- Remedy Coverity warning [Randers-Pehrson] +- Improve speed of gzprintf() in transparent mode +- Fix inflateInit2() bug when windowBits is 16 or 32 +- Change DEBUG macro to ZLIB_DEBUG +- Avoid uninitialized access by gzclose_w() +- Allow building zlib outside of the source directory +- Fix bug that accepted invalid zlib header when windowBits is zero +- Fix gzseek() problem on MinGW due to buggy _lseeki64 there +- Loop on write() calls in gzwrite.c in case of non-blocking I/O +- Add --warn (-w) option to ./configure for more compiler warnings +- Reject a window size of 256 bytes if not using the zlib wrapper +- Fix bug when level 0 used with Z_HUFFMAN or Z_RLE +- Add --debug (-d) option to ./configure to define ZLIB_DEBUG +- Fix bugs in creating a very large gzip header +- Add uncompress2() function, which returns the input size used +- Assure that deflateParams() will not switch functions mid-block +- Dramatically speed up deflation for level 0 (storing) +- Add gzfread(), duplicating the interface of fread() +- Add gzfwrite(), duplicating the interface of fwrite() +- Add deflateGetDictionary() function +- Use snprintf() for later versions of Microsoft C +- Fix *Init macros to use z_ prefix when requested +- Replace as400 with os400 for OS/400 support [Monnerat] +- Add crc32_z() and adler32_z() functions with size_t lengths +- Update Visual Studio project files [AraHaan] + Changes in 1.2.8 (28 Apr 2013) - Update contrib/minizip/iowin32.c for Windows RT [Vollant] - Do not force Z_CONST for C++ -- Clean up contrib/vstudio [Ro§] +- Clean up contrib/vstudio [Roß] - Correct spelling error in zlib.h - Fix mixed line endings in contrib/vstudio @@ -34,7 +77,7 @@ Changes in 1.2.7.1 (24 Mar 2013) - Clean up the usage of z_const and respect const usage within zlib - Clean up examples/gzlog.[ch] comparisons of different types - Avoid shift equal to bits in type (caused endless loop) -- Fix unintialized value bug in gzputc() introduced by const patches +- Fix uninitialized value bug in gzputc() introduced by const patches - Fix memory allocation error in examples/zran.c [Nor] - Fix bug where gzopen(), gzclose() would write an empty file - Fix bug in gzclose() when gzwrite() runs out of memory @@ -194,7 +237,7 @@ Changes in 1.2.5.2 (17 Dec 2011) - Add a transparent write mode to gzopen() when 'T' is in the mode - Update python link in zlib man page - Get inffixed.h and MAKEFIXED result to match -- Add a ./config --solo option to make zlib subset with no libary use +- Add a ./config --solo option to make zlib subset with no library use - Add undocumented inflateResetKeep() function for CAB file decoding - Add --cover option to ./configure for gcc coverage testing - Add #define ZLIB_CONST option to use const in the z_stream interface @@ -564,7 +607,7 @@ Changes in 1.2.3.1 (16 August 2006) - Update make_vms.com [Zinser] - Use -fPIC for shared build in configure [Teredesai, Nicholson] - Use only major version number for libz.so on IRIX and OSF1 [Reinholdtsen] -- Use fdopen() (not _fdopen()) for Interix in zutil.h [BŠck] +- Use fdopen() (not _fdopen()) for Interix in zutil.h [Bäck] - Add some FAQ entries about the contrib directory - Update the MVS question in the FAQ - Avoid extraneous reads after EOF in gzio.c [Brown] @@ -1178,7 +1221,7 @@ Changes in 1.0.6 (19 Jan 1998) 386 asm code replacing longest_match(). contrib/iostream/ by Kevin Ruland A C++ I/O streams interface to the zlib gz* functions - contrib/iostream2/ by Tyge Løvset + contrib/iostream2/ by Tyge Løvset Another C++ I/O streams interface contrib/untgz/ by "Pedro A. Aranda Guti\irrez" A very simple tar.gz file extractor using zlib @@ -1267,7 +1310,7 @@ Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion] - fix array overlay in deflate.c which sometimes caused bad compressed data - fix inflate bug with empty stored block - fix MSDOS medium model which was broken in 0.99 -- fix deflateParams() which could generated bad compressed data. +- fix deflateParams() which could generate bad compressed data. - Bytef is define'd instead of typedef'ed (work around Borland bug) - added an INDEX file - new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32), diff --git a/contrib/zlib/README b/contrib/zlib/README index 5ca9d12..51106de 100644 --- a/contrib/zlib/README +++ b/contrib/zlib/README @@ -1,6 +1,6 @@ ZLIB DATA COMPRESSION LIBRARY -zlib 1.2.8 is a general purpose data compression library. All the code is +zlib 1.2.11 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and @@ -31,7 +31,7 @@ Mark Nelson wrote an article about zlib for the Jan. 1997 issue of Dr. Dobb's Journal; a copy of the article is available at http://marknelson.us/1997/01/01/zlib-engine/ . -The changes made in version 1.2.8 are documented in the file ChangeLog. +The changes made in version 1.2.11 are documented in the file ChangeLog. Unsupported third party contributions are provided in directory contrib/ . @@ -84,7 +84,7 @@ Acknowledgments: Copyright notice: - (C) 1995-2013 Jean-loup Gailly and Mark Adler + (C) 1995-2017 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/contrib/zlib/adler32.c b/contrib/zlib/adler32.c index a868f07..d0be438 100644 --- a/contrib/zlib/adler32.c +++ b/contrib/zlib/adler32.c @@ -1,5 +1,5 @@ /* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2011 Mark Adler + * Copyright (C) 1995-2011, 2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -7,11 +7,9 @@ #include "zutil.h" -#define local static - local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); -#define BASE 65521 /* largest prime smaller than 65536 */ +#define BASE 65521U /* largest prime smaller than 65536 */ #define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ @@ -62,10 +60,10 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); #endif /* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) +uLong ZEXPORT adler32_z(adler, buf, len) uLong adler; const Bytef *buf; - uInt len; + z_size_t len; { unsigned long sum2; unsigned n; @@ -133,6 +131,15 @@ uLong ZEXPORT adler32(adler, buf, len) } /* ========================================================================= */ +uLong ZEXPORT adler32(adler, buf, len) + uLong adler; + const Bytef *buf; + uInt len; +{ + return adler32_z(adler, buf, len); +} + +/* ========================================================================= */ local uLong adler32_combine_(adler1, adler2, len2) uLong adler1; uLong adler2; @@ -156,7 +163,7 @@ local uLong adler32_combine_(adler1, adler2, len2) sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; if (sum1 >= BASE) sum1 -= BASE; if (sum1 >= BASE) sum1 -= BASE; - if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1); + if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1); if (sum2 >= BASE) sum2 -= BASE; return sum1 | (sum2 << 16); } diff --git a/contrib/zlib/compress.c b/contrib/zlib/compress.c index 6e97626..e2db404 100644 --- a/contrib/zlib/compress.c +++ b/contrib/zlib/compress.c @@ -1,5 +1,5 @@ /* compress.c -- compress a memory buffer - * Copyright (C) 1995-2005 Jean-loup Gailly. + * Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -28,16 +28,11 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) { z_stream stream; int err; + const uInt max = (uInt)-1; + uLong left; - stream.next_in = (z_const Bytef *)source; - stream.avail_in = (uInt)sourceLen; -#ifdef MAXSEG_64K - /* Check for source > 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; -#endif - stream.next_out = dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; + left = *destLen; + *destLen = 0; stream.zalloc = (alloc_func)0; stream.zfree = (free_func)0; @@ -46,15 +41,26 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) err = deflateInit(&stream, level); if (err != Z_OK) return err; - err = deflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - deflateEnd(&stream); - return err == Z_OK ? Z_BUF_ERROR : err; - } - *destLen = stream.total_out; + stream.next_out = dest; + stream.avail_out = 0; + stream.next_in = (z_const Bytef *)source; + stream.avail_in = 0; + + do { + if (stream.avail_out == 0) { + stream.avail_out = left > (uLong)max ? max : (uInt)left; + left -= stream.avail_out; + } + if (stream.avail_in == 0) { + stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen; + sourceLen -= stream.avail_in; + } + err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH); + } while (err == Z_OK); - err = deflateEnd(&stream); - return err; + *destLen = stream.total_out; + deflateEnd(&stream); + return err == Z_STREAM_END ? Z_OK : err; } /* =========================================================================== diff --git a/contrib/zlib/contrib/README.contrib b/contrib/zlib/contrib/README.contrib index c66349b..a411d5c 100644 --- a/contrib/zlib/contrib/README.contrib +++ b/contrib/zlib/contrib/README.contrib @@ -38,7 +38,7 @@ inflate86/ by Chris Anderson iostream/ by Kevin Ruland A C++ I/O streams interface to the zlib gz* functions -iostream2/ by Tyge Løvset +iostream2/ by Tyge Løvset Another C++ I/O streams interface iostream3/ by Ludwig Schwardt @@ -58,7 +58,7 @@ masmx86/ by Gilles Vollant minizip/ by Gilles Vollant Mini zip and unzip based on zlib Includes Zip64 support by Mathias Svensson - See http://www.winimage.com/zLibDll/unzip.html + See http://www.winimage.com/zLibDll/minizip.html pascal/ by Bob Dellaca et al. Support for Pascal diff --git a/contrib/zlib/crc32.c b/contrib/zlib/crc32.c index 979a719..9580440 100644 --- a/contrib/zlib/crc32.c +++ b/contrib/zlib/crc32.c @@ -1,5 +1,5 @@ /* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler + * Copyright (C) 1995-2006, 2010, 2011, 2012, 2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h * * Thanks to Rodney Brown for his contribution of faster @@ -30,17 +30,15 @@ #include "zutil.h" /* for STDC and FAR definitions */ -#define local static - /* Definitions for doing the crc four data bytes at a time. */ #if !defined(NOBYFOUR) && defined(Z_U4) # define BYFOUR #endif #ifdef BYFOUR local unsigned long crc32_little OF((unsigned long, - const unsigned char FAR *, unsigned)); + const unsigned char FAR *, z_size_t)); local unsigned long crc32_big OF((unsigned long, - const unsigned char FAR *, unsigned)); + const unsigned char FAR *, z_size_t)); # define TBLS 8 #else # define TBLS 1 @@ -201,10 +199,10 @@ const z_crc_t FAR * ZEXPORT get_crc_table() #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 /* ========================================================================= */ -unsigned long ZEXPORT crc32(crc, buf, len) +unsigned long ZEXPORT crc32_z(crc, buf, len) unsigned long crc; const unsigned char FAR *buf; - uInt len; + z_size_t len; { if (buf == Z_NULL) return 0UL; @@ -235,8 +233,29 @@ unsigned long ZEXPORT crc32(crc, buf, len) return crc ^ 0xffffffffUL; } +/* ========================================================================= */ +unsigned long ZEXPORT crc32(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + uInt len; +{ + return crc32_z(crc, buf, len); +} + #ifdef BYFOUR +/* + This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit + integer pointer type. This violates the strict aliasing rule, where a + compiler can assume, for optimization purposes, that two pointers to + fundamentally different types won't ever point to the same memory. This can + manifest as a problem only if one of the pointers is written to. This code + only reads from those pointers. So long as this code remains isolated in + this compilation unit, there won't be a problem. For this reason, this code + should not be copied and pasted into a compilation unit in which other code + writes to the buffer that is passed to these routines. + */ + /* ========================================================================= */ #define DOLIT4 c ^= *buf4++; \ c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ @@ -247,7 +266,7 @@ unsigned long ZEXPORT crc32(crc, buf, len) local unsigned long crc32_little(crc, buf, len) unsigned long crc; const unsigned char FAR *buf; - unsigned len; + z_size_t len; { register z_crc_t c; register const z_crc_t FAR *buf4; @@ -278,7 +297,7 @@ local unsigned long crc32_little(crc, buf, len) } /* ========================================================================= */ -#define DOBIG4 c ^= *++buf4; \ +#define DOBIG4 c ^= *buf4++; \ c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] #define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 @@ -287,7 +306,7 @@ local unsigned long crc32_little(crc, buf, len) local unsigned long crc32_big(crc, buf, len) unsigned long crc; const unsigned char FAR *buf; - unsigned len; + z_size_t len; { register z_crc_t c; register const z_crc_t FAR *buf4; @@ -300,7 +319,6 @@ local unsigned long crc32_big(crc, buf, len) } buf4 = (const z_crc_t FAR *)(const void FAR *)buf; - buf4--; while (len >= 32) { DOBIG32; len -= 32; @@ -309,7 +327,6 @@ local unsigned long crc32_big(crc, buf, len) DOBIG4; len -= 4; } - buf4++; buf = (const unsigned char FAR *)buf4; if (len) do { diff --git a/contrib/zlib/deflate.c b/contrib/zlib/deflate.c index 6969577..1ec7614 100644 --- a/contrib/zlib/deflate.c +++ b/contrib/zlib/deflate.c @@ -1,5 +1,5 @@ /* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler + * Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -52,7 +52,7 @@ #include "deflate.h" const char deflate_copyright[] = - " deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler "; + " deflate 1.2.11 Copyright 1995-2017 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -73,6 +73,8 @@ typedef enum { typedef block_state (*compress_func) OF((deflate_state *s, int flush)); /* Compression function. Returns the block state after the call. */ +local int deflateStateCheck OF((z_streamp strm)); +local void slide_hash OF((deflate_state *s)); local void fill_window OF((deflate_state *s)); local block_state deflate_stored OF((deflate_state *s, int flush)); local block_state deflate_fast OF((deflate_state *s, int flush)); @@ -84,15 +86,16 @@ local block_state deflate_huff OF((deflate_state *s, int flush)); local void lm_init OF((deflate_state *s)); local void putShortMSB OF((deflate_state *s, uInt b)); local void flush_pending OF((z_streamp strm)); -local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); +local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); #ifdef ASMV +# pragma message("Assembler code may have bugs -- use at your own risk") void match_init OF((void)); /* asm code initialization */ uInt longest_match OF((deflate_state *s, IPos cur_match)); #else local uInt longest_match OF((deflate_state *s, IPos cur_match)); #endif -#ifdef DEBUG +#ifdef ZLIB_DEBUG local void check_match OF((deflate_state *s, IPos start, IPos match, int length)); #endif @@ -148,21 +151,14 @@ local const config configuration_table[10] = { * meaning. */ -#define EQUAL 0 -/* result of memcmp for equal strings */ - -#ifndef NO_DUMMY_DECL -struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ -#endif - /* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */ -#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0)) +#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0)) /* =========================================================================== * Update a hash value with the given input byte - * IN assertion: all calls to to UPDATE_HASH are made with consecutive - * input characters, so that a running hash key can be computed from the - * previous key instead of complete recalculation each time. + * IN assertion: all calls to UPDATE_HASH are made with consecutive input + * characters, so that a running hash key can be computed from the previous + * key instead of complete recalculation each time. */ #define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) @@ -173,9 +169,9 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ * the previous length of the hash chain. * If this file is compiled with -DFASTEST, the compression level is forced * to 1, and no hash chains are maintained. - * IN assertion: all calls to to INSERT_STRING are made with consecutive - * input characters and the first MIN_MATCH bytes of str are valid - * (except for the last MIN_MATCH-1 bytes of the input file). + * IN assertion: all calls to INSERT_STRING are made with consecutive input + * characters and the first MIN_MATCH bytes of str are valid (except for + * the last MIN_MATCH-1 bytes of the input file). */ #ifdef FASTEST #define INSERT_STRING(s, str, match_head) \ @@ -197,6 +193,37 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ s->head[s->hash_size-1] = NIL; \ zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); +/* =========================================================================== + * Slide the hash table when sliding the window down (could be avoided with 32 + * bit values at the expense of memory usage). We slide even when level == 0 to + * keep the hash table consistent if we switch back to level > 0 later. + */ +local void slide_hash(s) + deflate_state *s; +{ + unsigned n, m; + Posf *p; + uInt wsize = s->w_size; + + n = s->hash_size; + p = &s->head[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m - wsize : NIL); + } while (--n); + n = wsize; +#ifndef FASTEST + p = &s->prev[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m - wsize : NIL); + /* If n is not on any hash chain, prev[n] is garbage but + * its value will never be used. + */ + } while (--n); +#endif +} + /* ========================================================================= */ int ZEXPORT deflateInit_(strm, level, version, stream_size) z_streamp strm; @@ -270,7 +297,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, #endif if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_FIXED) { + strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) { return Z_STREAM_ERROR; } if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ @@ -278,14 +305,15 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, if (s == Z_NULL) return Z_MEM_ERROR; strm->state = (struct internal_state FAR *)s; s->strm = strm; + s->status = INIT_STATE; /* to pass state test in deflateReset() */ s->wrap = wrap; s->gzhead = Z_NULL; - s->w_bits = windowBits; + s->w_bits = (uInt)windowBits; s->w_size = 1 << s->w_bits; s->w_mask = s->w_size - 1; - s->hash_bits = memLevel + 7; + s->hash_bits = (uInt)memLevel + 7; s->hash_size = 1 << s->hash_bits; s->hash_mask = s->hash_size - 1; s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); @@ -319,6 +347,31 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, return deflateReset(strm); } +/* ========================================================================= + * Check for a valid deflate stream state. Return 0 if ok, 1 if not. + */ +local int deflateStateCheck (strm) + z_streamp strm; +{ + deflate_state *s; + if (strm == Z_NULL || + strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) + return 1; + s = strm->state; + if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE && +#ifdef GZIP + s->status != GZIP_STATE && +#endif + s->status != EXTRA_STATE && + s->status != NAME_STATE && + s->status != COMMENT_STATE && + s->status != HCRC_STATE && + s->status != BUSY_STATE && + s->status != FINISH_STATE)) + return 1; + return 0; +} + /* ========================================================================= */ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) z_streamp strm; @@ -331,7 +384,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) unsigned avail; z_const unsigned char *next; - if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL) + if (deflateStateCheck(strm) || dictionary == Z_NULL) return Z_STREAM_ERROR; s = strm->state; wrap = s->wrap; @@ -389,13 +442,34 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) } /* ========================================================================= */ +int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength) + z_streamp strm; + Bytef *dictionary; + uInt *dictLength; +{ + deflate_state *s; + uInt len; + + if (deflateStateCheck(strm)) + return Z_STREAM_ERROR; + s = strm->state; + len = s->strstart + s->lookahead; + if (len > s->w_size) + len = s->w_size; + if (dictionary != Z_NULL && len) + zmemcpy(dictionary, s->window + s->strstart + s->lookahead - len, len); + if (dictLength != Z_NULL) + *dictLength = len; + return Z_OK; +} + +/* ========================================================================= */ int ZEXPORT deflateResetKeep (strm) z_streamp strm; { deflate_state *s; - if (strm == Z_NULL || strm->state == Z_NULL || - strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) { + if (deflateStateCheck(strm)) { return Z_STREAM_ERROR; } @@ -410,7 +484,11 @@ int ZEXPORT deflateResetKeep (strm) if (s->wrap < 0) { s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ } - s->status = s->wrap ? INIT_STATE : BUSY_STATE; + s->status = +#ifdef GZIP + s->wrap == 2 ? GZIP_STATE : +#endif + s->wrap ? INIT_STATE : BUSY_STATE; strm->adler = #ifdef GZIP s->wrap == 2 ? crc32(0L, Z_NULL, 0) : @@ -440,8 +518,8 @@ int ZEXPORT deflateSetHeader (strm, head) z_streamp strm; gz_headerp head; { - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - if (strm->state->wrap != 2) return Z_STREAM_ERROR; + if (deflateStateCheck(strm) || strm->state->wrap != 2) + return Z_STREAM_ERROR; strm->state->gzhead = head; return Z_OK; } @@ -452,7 +530,7 @@ int ZEXPORT deflatePending (strm, pending, bits) int *bits; z_streamp strm; { - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; if (pending != Z_NULL) *pending = strm->state->pending; if (bits != Z_NULL) @@ -469,7 +547,7 @@ int ZEXPORT deflatePrime (strm, bits, value) deflate_state *s; int put; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3)) return Z_BUF_ERROR; @@ -494,9 +572,8 @@ int ZEXPORT deflateParams(strm, level, strategy) { deflate_state *s; compress_func func; - int err = Z_OK; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; #ifdef FASTEST @@ -510,13 +587,22 @@ int ZEXPORT deflateParams(strm, level, strategy) func = configuration_table[s->level].func; if ((strategy != s->strategy || func != configuration_table[level].func) && - strm->total_in != 0) { + s->high_water) { /* Flush the last buffer: */ - err = deflate(strm, Z_BLOCK); - if (err == Z_BUF_ERROR && s->pending == 0) - err = Z_OK; + int err = deflate(strm, Z_BLOCK); + if (err == Z_STREAM_ERROR) + return err; + if (strm->avail_out == 0) + return Z_BUF_ERROR; } if (s->level != level) { + if (s->level == 0 && s->matches != 0) { + if (s->matches == 1) + slide_hash(s); + else + CLEAR_HASH(s); + s->matches = 0; + } s->level = level; s->max_lazy_match = configuration_table[level].max_lazy; s->good_match = configuration_table[level].good_length; @@ -524,7 +610,7 @@ int ZEXPORT deflateParams(strm, level, strategy) s->max_chain_length = configuration_table[level].max_chain; } s->strategy = strategy; - return err; + return Z_OK; } /* ========================================================================= */ @@ -537,12 +623,12 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) { deflate_state *s; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; - s->good_match = good_length; - s->max_lazy_match = max_lazy; + s->good_match = (uInt)good_length; + s->max_lazy_match = (uInt)max_lazy; s->nice_match = nice_length; - s->max_chain_length = max_chain; + s->max_chain_length = (uInt)max_chain; return Z_OK; } @@ -569,14 +655,13 @@ uLong ZEXPORT deflateBound(strm, sourceLen) { deflate_state *s; uLong complen, wraplen; - Bytef *str; /* conservative upper bound for compressed data */ complen = sourceLen + ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5; /* if can't get parameters, return conservative bound plus zlib wrapper */ - if (strm == Z_NULL || strm->state == Z_NULL) + if (deflateStateCheck(strm)) return complen + 6; /* compute wrapper length */ @@ -588,9 +673,11 @@ uLong ZEXPORT deflateBound(strm, sourceLen) case 1: /* zlib wrapper */ wraplen = 6 + (s->strstart ? 4 : 0); break; +#ifdef GZIP case 2: /* gzip wrapper */ wraplen = 18; if (s->gzhead != Z_NULL) { /* user-supplied gzip header */ + Bytef *str; if (s->gzhead->extra != Z_NULL) wraplen += 2 + s->gzhead->extra_len; str = s->gzhead->name; @@ -607,6 +694,7 @@ uLong ZEXPORT deflateBound(strm, sourceLen) wraplen += 2; } break; +#endif default: /* for compiler happiness */ wraplen = 6; } @@ -634,10 +722,10 @@ local void putShortMSB (s, b) } /* ========================================================================= - * Flush as much pending output as possible. All deflate() output goes - * through this function so some applications may wish to modify it - * to avoid allocating a large strm->next_out buffer and copying into it. - * (See also read_buf()). + * Flush as much pending output as possible. All deflate() output, except for + * some deflate_stored() output, goes through this function so some + * applications may wish to modify it to avoid allocating a large + * strm->next_out buffer and copying into it. (See also read_buf()). */ local void flush_pending(strm) z_streamp strm; @@ -654,13 +742,23 @@ local void flush_pending(strm) strm->next_out += len; s->pending_out += len; strm->total_out += len; - strm->avail_out -= len; - s->pending -= len; + strm->avail_out -= len; + s->pending -= len; if (s->pending == 0) { s->pending_out = s->pending_buf; } } +/* =========================================================================== + * Update the header CRC with the bytes s->pending_buf[beg..s->pending - 1]. + */ +#define HCRC_UPDATE(beg) \ + do { \ + if (s->gzhead->hcrc && s->pending > (beg)) \ + strm->adler = crc32(strm->adler, s->pending_buf + (beg), \ + s->pending - (beg)); \ + } while (0) + /* ========================================================================= */ int ZEXPORT deflate (strm, flush) z_streamp strm; @@ -669,230 +767,229 @@ int ZEXPORT deflate (strm, flush) int old_flush; /* value of flush param for previous deflate call */ deflate_state *s; - if (strm == Z_NULL || strm->state == Z_NULL || - flush > Z_BLOCK || flush < 0) { + if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) { return Z_STREAM_ERROR; } s = strm->state; if (strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0) || + (strm->avail_in != 0 && strm->next_in == Z_NULL) || (s->status == FINISH_STATE && flush != Z_FINISH)) { ERR_RETURN(strm, Z_STREAM_ERROR); } if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); - s->strm = strm; /* just in case */ old_flush = s->last_flush; s->last_flush = flush; + /* Flush as much pending output as possible */ + if (s->pending != 0) { + flush_pending(strm); + if (strm->avail_out == 0) { + /* Since avail_out is 0, deflate will be called again with + * more output space, but possibly with both pending and + * avail_in equal to zero. There won't be anything to do, + * but this is not an error situation so make sure we + * return OK instead of BUF_ERROR at next call of deflate: + */ + s->last_flush = -1; + return Z_OK; + } + + /* Make sure there is something to do and avoid duplicate consecutive + * flushes. For repeated and useless calls with Z_FINISH, we keep + * returning Z_STREAM_END instead of Z_BUF_ERROR. + */ + } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && + flush != Z_FINISH) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + + /* User must not provide more input after the first FINISH: */ + if (s->status == FINISH_STATE && strm->avail_in != 0) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + /* Write the header */ if (s->status == INIT_STATE) { -#ifdef GZIP - if (s->wrap == 2) { - strm->adler = crc32(0L, Z_NULL, 0); - put_byte(s, 31); - put_byte(s, 139); - put_byte(s, 8); - if (s->gzhead == Z_NULL) { - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, OS_CODE); - s->status = BUSY_STATE; - } - else { - put_byte(s, (s->gzhead->text ? 1 : 0) + - (s->gzhead->hcrc ? 2 : 0) + - (s->gzhead->extra == Z_NULL ? 0 : 4) + - (s->gzhead->name == Z_NULL ? 0 : 8) + - (s->gzhead->comment == Z_NULL ? 0 : 16) - ); - put_byte(s, (Byte)(s->gzhead->time & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, s->gzhead->os & 0xff); - if (s->gzhead->extra != Z_NULL) { - put_byte(s, s->gzhead->extra_len & 0xff); - put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); - } - if (s->gzhead->hcrc) - strm->adler = crc32(strm->adler, s->pending_buf, - s->pending); - s->gzindex = 0; - s->status = EXTRA_STATE; - } - } + /* zlib header */ + uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; + uInt level_flags; + + if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) + level_flags = 0; + else if (s->level < 6) + level_flags = 1; + else if (s->level == 6) + level_flags = 2; else -#endif - { - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; - uInt level_flags; - - if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) - level_flags = 0; - else if (s->level < 6) - level_flags = 1; - else if (s->level == 6) - level_flags = 2; - else - level_flags = 3; - header |= (level_flags << 6); - if (s->strstart != 0) header |= PRESET_DICT; - header += 31 - (header % 31); + level_flags = 3; + header |= (level_flags << 6); + if (s->strstart != 0) header |= PRESET_DICT; + header += 31 - (header % 31); + + putShortMSB(s, header); + /* Save the adler32 of the preset dictionary: */ + if (s->strstart != 0) { + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + strm->adler = adler32(0L, Z_NULL, 0); + s->status = BUSY_STATE; + + /* Compression must start with an empty pending buffer */ + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + } +#ifdef GZIP + if (s->status == GZIP_STATE) { + /* gzip header */ + strm->adler = crc32(0L, Z_NULL, 0); + put_byte(s, 31); + put_byte(s, 139); + put_byte(s, 8); + if (s->gzhead == Z_NULL) { + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, s->level == 9 ? 2 : + (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? + 4 : 0)); + put_byte(s, OS_CODE); s->status = BUSY_STATE; - putShortMSB(s, header); - /* Save the adler32 of the preset dictionary: */ - if (s->strstart != 0) { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); + /* Compression must start with an empty pending buffer */ + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + } + else { + put_byte(s, (s->gzhead->text ? 1 : 0) + + (s->gzhead->hcrc ? 2 : 0) + + (s->gzhead->extra == Z_NULL ? 0 : 4) + + (s->gzhead->name == Z_NULL ? 0 : 8) + + (s->gzhead->comment == Z_NULL ? 0 : 16) + ); + put_byte(s, (Byte)(s->gzhead->time & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); + put_byte(s, s->level == 9 ? 2 : + (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? + 4 : 0)); + put_byte(s, s->gzhead->os & 0xff); + if (s->gzhead->extra != Z_NULL) { + put_byte(s, s->gzhead->extra_len & 0xff); + put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); } - strm->adler = adler32(0L, Z_NULL, 0); + if (s->gzhead->hcrc) + strm->adler = crc32(strm->adler, s->pending_buf, + s->pending); + s->gzindex = 0; + s->status = EXTRA_STATE; } } -#ifdef GZIP if (s->status == EXTRA_STATE) { if (s->gzhead->extra != Z_NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - - while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) - break; + ulg beg = s->pending; /* start of bytes to update crc */ + uInt left = (s->gzhead->extra_len & 0xffff) - s->gzindex; + while (s->pending + left > s->pending_buf_size) { + uInt copy = s->pending_buf_size - s->pending; + zmemcpy(s->pending_buf + s->pending, + s->gzhead->extra + s->gzindex, copy); + s->pending = s->pending_buf_size; + HCRC_UPDATE(beg); + s->gzindex += copy; + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; } - put_byte(s, s->gzhead->extra[s->gzindex]); - s->gzindex++; - } - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (s->gzindex == s->gzhead->extra_len) { - s->gzindex = 0; - s->status = NAME_STATE; + beg = 0; + left -= copy; } + zmemcpy(s->pending_buf + s->pending, + s->gzhead->extra + s->gzindex, left); + s->pending += left; + HCRC_UPDATE(beg); + s->gzindex = 0; } - else - s->status = NAME_STATE; + s->status = NAME_STATE; } if (s->status == NAME_STATE) { if (s->gzhead->name != Z_NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ + ulg beg = s->pending; /* start of bytes to update crc */ int val; - do { if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); + HCRC_UPDATE(beg); flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; } + beg = 0; } val = s->gzhead->name[s->gzindex++]; put_byte(s, val); } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) { - s->gzindex = 0; - s->status = COMMENT_STATE; - } + HCRC_UPDATE(beg); + s->gzindex = 0; } - else - s->status = COMMENT_STATE; + s->status = COMMENT_STATE; } if (s->status == COMMENT_STATE) { if (s->gzhead->comment != Z_NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ + ulg beg = s->pending; /* start of bytes to update crc */ int val; - do { if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); + HCRC_UPDATE(beg); flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; } + beg = 0; } val = s->gzhead->comment[s->gzindex++]; put_byte(s, val); } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) - s->status = HCRC_STATE; + HCRC_UPDATE(beg); } - else - s->status = HCRC_STATE; + s->status = HCRC_STATE; } if (s->status == HCRC_STATE) { if (s->gzhead->hcrc) { - if (s->pending + 2 > s->pending_buf_size) + if (s->pending + 2 > s->pending_buf_size) { flush_pending(strm); - if (s->pending + 2 <= s->pending_buf_size) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - strm->adler = crc32(0L, Z_NULL, 0); - s->status = BUSY_STATE; + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } } + put_byte(s, (Byte)(strm->adler & 0xff)); + put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); + strm->adler = crc32(0L, Z_NULL, 0); } - else - s->status = BUSY_STATE; - } -#endif + s->status = BUSY_STATE; - /* Flush as much pending output as possible */ - if (s->pending != 0) { + /* Compression must start with an empty pending buffer */ flush_pending(strm); - if (strm->avail_out == 0) { - /* Since avail_out is 0, deflate will be called again with - * more output space, but possibly with both pending and - * avail_in equal to zero. There won't be anything to do, - * but this is not an error situation so make sure we - * return OK instead of BUF_ERROR at next call of deflate: - */ + if (s->pending != 0) { s->last_flush = -1; return Z_OK; } - - /* Make sure there is something to do and avoid duplicate consecutive - * flushes. For repeated and useless calls with Z_FINISH, we keep - * returning Z_STREAM_END instead of Z_BUF_ERROR. - */ - } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && - flush != Z_FINISH) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* User must not provide more input after the first FINISH: */ - if (s->status == FINISH_STATE && strm->avail_in != 0) { - ERR_RETURN(strm, Z_BUF_ERROR); } +#endif /* Start a new block or continue the current one. */ @@ -900,9 +997,10 @@ int ZEXPORT deflate (strm, flush) (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { block_state bstate; - bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : - (s->strategy == Z_RLE ? deflate_rle(s, flush) : - (*(configuration_table[s->level].func))(s, flush)); + bstate = s->level == 0 ? deflate_stored(s, flush) : + s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : + s->strategy == Z_RLE ? deflate_rle(s, flush) : + (*(configuration_table[s->level].func))(s, flush); if (bstate == finish_started || bstate == finish_done) { s->status = FINISH_STATE; @@ -944,7 +1042,6 @@ int ZEXPORT deflate (strm, flush) } } } - Assert(strm->avail_out > 0, "bug2"); if (flush != Z_FINISH) return Z_OK; if (s->wrap <= 0) return Z_STREAM_END; @@ -981,18 +1078,9 @@ int ZEXPORT deflateEnd (strm) { int status; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; status = strm->state->status; - if (status != INIT_STATE && - status != EXTRA_STATE && - status != NAME_STATE && - status != COMMENT_STATE && - status != HCRC_STATE && - status != BUSY_STATE && - status != FINISH_STATE) { - return Z_STREAM_ERROR; - } /* Deallocate in reverse order of allocations: */ TRY_FREE(strm, strm->state->pending_buf); @@ -1023,7 +1111,7 @@ int ZEXPORT deflateCopy (dest, source) ushf *overlay; - if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { + if (deflateStateCheck(source) || dest == Z_NULL) { return Z_STREAM_ERROR; } @@ -1073,7 +1161,7 @@ int ZEXPORT deflateCopy (dest, source) * allocating a large strm->next_in buffer and copying from it. * (See also flush_pending()). */ -local int read_buf(strm, buf, size) +local unsigned read_buf(strm, buf, size) z_streamp strm; Bytef *buf; unsigned size; @@ -1097,7 +1185,7 @@ local int read_buf(strm, buf, size) strm->next_in += len; strm->total_in += len; - return (int)len; + return len; } /* =========================================================================== @@ -1151,9 +1239,9 @@ local uInt longest_match(s, cur_match) { unsigned chain_length = s->max_chain_length;/* max hash chain length */ register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ + register Bytef *match; /* matched string */ register int len; /* length of current match */ - int best_len = s->prev_length; /* best match length so far */ + int best_len = (int)s->prev_length; /* best match length so far */ int nice_match = s->nice_match; /* stop if match long enough */ IPos limit = s->strstart > (IPos)MAX_DIST(s) ? s->strstart - (IPos)MAX_DIST(s) : NIL; @@ -1188,7 +1276,7 @@ local uInt longest_match(s, cur_match) /* Do not look for matches beyond the end of the input. This is necessary * to make deflate deterministic. */ - if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead; Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); @@ -1349,7 +1437,11 @@ local uInt longest_match(s, cur_match) #endif /* FASTEST */ -#ifdef DEBUG +#ifdef ZLIB_DEBUG + +#define EQUAL 0 +/* result of memcmp for equal strings */ + /* =========================================================================== * Check that the match at match_start is indeed a match. */ @@ -1375,7 +1467,7 @@ local void check_match(s, start, match, length) } #else # define check_match(s, start, match, length) -#endif /* DEBUG */ +#endif /* ZLIB_DEBUG */ /* =========================================================================== * Fill the window when the lookahead becomes insufficient. @@ -1390,8 +1482,7 @@ local void check_match(s, start, match, length) local void fill_window(s) deflate_state *s; { - register unsigned n, m; - register Posf *p; + unsigned n; unsigned more; /* Amount of free space at the end of the window. */ uInt wsize = s->w_size; @@ -1418,35 +1509,11 @@ local void fill_window(s) */ if (s->strstart >= wsize+MAX_DIST(s)) { - zmemcpy(s->window, s->window+wsize, (unsigned)wsize); + zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more); s->match_start -= wsize; s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ s->block_start -= (long) wsize; - - /* Slide the hash table (could be avoided with 32 bit values - at the expense of memory usage). We slide even when level == 0 - to keep the hash table consistent if we switch back to level > 0 - later. (Using level 0 permanently is not an optimal usage of - zlib, so we don't care about this pathological case.) - */ - n = s->hash_size; - p = &s->head[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - } while (--n); - - n = wsize; -#ifndef FASTEST - p = &s->prev[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); -#endif + slide_hash(s); more += wsize; } if (s->strm->avail_in == 0) break; @@ -1552,70 +1619,199 @@ local void fill_window(s) if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \ } +/* Maximum stored block length in deflate format (not including header). */ +#define MAX_STORED 65535 + +/* Minimum of a and b. */ +#define MIN(a, b) ((a) > (b) ? (b) : (a)) + /* =========================================================================== * Copy without compression as much as possible from the input stream, return * the current block state. - * This function does not insert new strings in the dictionary since - * uncompressible data is probably not useful. This function is used - * only for the level=0 compression option. - * NOTE: this function should be optimized to avoid extra copying from - * window to pending_buf. + * + * In case deflateParams() is used to later switch to a non-zero compression + * level, s->matches (otherwise unused when storing) keeps track of the number + * of hash table slides to perform. If s->matches is 1, then one hash table + * slide will be done when switching. If s->matches is 2, the maximum value + * allowed here, then the hash table will be cleared, since two or more slides + * is the same as a clear. + * + * deflate_stored() is written to minimize the number of times an input byte is + * copied. It is most efficient with large input and output buffers, which + * maximizes the opportunites to have a single copy from next_in to next_out. */ local block_state deflate_stored(s, flush) deflate_state *s; int flush; { - /* Stored blocks are limited to 0xffff bytes, pending_buf is limited - * to pending_buf_size, and each stored block has a 5 byte header: + /* Smallest worthy block size when not flushing or finishing. By default + * this is 32K. This can be as small as 507 bytes for memLevel == 1. For + * large input and output buffers, the stored block size will be larger. */ - ulg max_block_size = 0xffff; - ulg max_start; - - if (max_block_size > s->pending_buf_size - 5) { - max_block_size = s->pending_buf_size - 5; - } + unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size); - /* Copy as much as possible from input to output: */ - for (;;) { - /* Fill the window as much as possible: */ - if (s->lookahead <= 1) { - - Assert(s->strstart < s->w_size+MAX_DIST(s) || - s->block_start >= (long)s->w_size, "slide too late"); + /* Copy as many min_block or larger stored blocks directly to next_out as + * possible. If flushing, copy the remaining available input to next_out as + * stored blocks, if there is enough space. + */ + unsigned len, left, have, last = 0; + unsigned used = s->strm->avail_in; + do { + /* Set len to the maximum size block that we can copy directly with the + * available input data and output space. Set left to how much of that + * would be copied from what's left in the window. + */ + len = MAX_STORED; /* maximum deflate stored block length */ + have = (s->bi_valid + 42) >> 3; /* number of header bytes */ + if (s->strm->avail_out < have) /* need room for header */ + break; + /* maximum stored block length that will fit in avail_out: */ + have = s->strm->avail_out - have; + left = s->strstart - s->block_start; /* bytes left in window */ + if (len > (ulg)left + s->strm->avail_in) + len = left + s->strm->avail_in; /* limit len to the input */ + if (len > have) + len = have; /* limit len to the output */ + + /* If the stored block would be less than min_block in length, or if + * unable to copy all of the available input when flushing, then try + * copying to the window and the pending buffer instead. Also don't + * write an empty block when flushing -- deflate() does that. + */ + if (len < min_block && ((len == 0 && flush != Z_FINISH) || + flush == Z_NO_FLUSH || + len != left + s->strm->avail_in)) + break; - fill_window(s); - if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; + /* Make a dummy stored block in pending to get the header bytes, + * including any pending bits. This also updates the debugging counts. + */ + last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0; + _tr_stored_block(s, (char *)0, 0L, last); + + /* Replace the lengths in the dummy stored block with len. */ + s->pending_buf[s->pending - 4] = len; + s->pending_buf[s->pending - 3] = len >> 8; + s->pending_buf[s->pending - 2] = ~len; + s->pending_buf[s->pending - 1] = ~len >> 8; + + /* Write the stored block header bytes. */ + flush_pending(s->strm); + +#ifdef ZLIB_DEBUG + /* Update debugging counts for the data about to be copied. */ + s->compressed_len += len << 3; + s->bits_sent += len << 3; +#endif - if (s->lookahead == 0) break; /* flush the current block */ + /* Copy uncompressed bytes from the window to next_out. */ + if (left) { + if (left > len) + left = len; + zmemcpy(s->strm->next_out, s->window + s->block_start, left); + s->strm->next_out += left; + s->strm->avail_out -= left; + s->strm->total_out += left; + s->block_start += left; + len -= left; } - Assert(s->block_start >= 0L, "block gone"); - - s->strstart += s->lookahead; - s->lookahead = 0; - - /* Emit a stored block if pending_buf will be full: */ - max_start = s->block_start + max_block_size; - if (s->strstart == 0 || (ulg)s->strstart >= max_start) { - /* strstart == 0 is possible when wraparound on 16-bit machine */ - s->lookahead = (uInt)(s->strstart - max_start); - s->strstart = (uInt)max_start; - FLUSH_BLOCK(s, 0); + + /* Copy uncompressed bytes directly from next_in to next_out, updating + * the check value. + */ + if (len) { + read_buf(s->strm, s->strm->next_out, len); + s->strm->next_out += len; + s->strm->avail_out -= len; + s->strm->total_out += len; } - /* Flush if we may have to slide, otherwise block_start may become - * negative and the data will be gone: + } while (last == 0); + + /* Update the sliding window with the last s->w_size bytes of the copied + * data, or append all of the copied data to the existing window if less + * than s->w_size bytes were copied. Also update the number of bytes to + * insert in the hash tables, in the event that deflateParams() switches to + * a non-zero compression level. + */ + used -= s->strm->avail_in; /* number of input bytes directly copied */ + if (used) { + /* If any input was used, then no unused input remains in the window, + * therefore s->block_start == s->strstart. */ - if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { - FLUSH_BLOCK(s, 0); + if (used >= s->w_size) { /* supplant the previous history */ + s->matches = 2; /* clear hash */ + zmemcpy(s->window, s->strm->next_in - s->w_size, s->w_size); + s->strstart = s->w_size; } + else { + if (s->window_size - s->strstart <= used) { + /* Slide the window down. */ + s->strstart -= s->w_size; + zmemcpy(s->window, s->window + s->w_size, s->strstart); + if (s->matches < 2) + s->matches++; /* add a pending slide_hash() */ + } + zmemcpy(s->window + s->strstart, s->strm->next_in - used, used); + s->strstart += used; + } + s->block_start = s->strstart; + s->insert += MIN(used, s->w_size - s->insert); } - s->insert = 0; - if (flush == Z_FINISH) { - FLUSH_BLOCK(s, 1); + if (s->high_water < s->strstart) + s->high_water = s->strstart; + + /* If the last block was written to next_out, then done. */ + if (last) return finish_done; + + /* If flushing and all input has been consumed, then done. */ + if (flush != Z_NO_FLUSH && flush != Z_FINISH && + s->strm->avail_in == 0 && (long)s->strstart == s->block_start) + return block_done; + + /* Fill the window with any remaining input. */ + have = s->window_size - s->strstart - 1; + if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) { + /* Slide the window down. */ + s->block_start -= s->w_size; + s->strstart -= s->w_size; + zmemcpy(s->window, s->window + s->w_size, s->strstart); + if (s->matches < 2) + s->matches++; /* add a pending slide_hash() */ + have += s->w_size; /* more space now */ } - if ((long)s->strstart > s->block_start) - FLUSH_BLOCK(s, 0); - return block_done; + if (have > s->strm->avail_in) + have = s->strm->avail_in; + if (have) { + read_buf(s->strm, s->window + s->strstart, have); + s->strstart += have; + } + if (s->high_water < s->strstart) + s->high_water = s->strstart; + + /* There was not enough avail_out to write a complete worthy or flushed + * stored block to next_out. Write a stored block to pending instead, if we + * have enough input for a worthy block, or if flushing and there is enough + * room for the remaining input as a stored block in the pending buffer. + */ + have = (s->bi_valid + 42) >> 3; /* number of header bytes */ + /* maximum stored block length that will fit in pending: */ + have = MIN(s->pending_buf_size - have, MAX_STORED); + min_block = MIN(have, s->w_size); + left = s->strstart - s->block_start; + if (left >= min_block || + ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH && + s->strm->avail_in == 0 && left <= have)) { + len = MIN(left, have); + last = flush == Z_FINISH && s->strm->avail_in == 0 && + len == left ? 1 : 0; + _tr_stored_block(s, (charf *)s->window + s->block_start, len, last); + s->block_start += len; + flush_pending(s->strm); + } + + /* We've done all we can with the available input and output. */ + return last ? finish_started : need_more; } /* =========================================================================== @@ -1892,7 +2088,7 @@ local block_state deflate_rle(s, flush) prev == *++scan && prev == *++scan && prev == *++scan && prev == *++scan && scan < strend); - s->match_length = MAX_MATCH - (int)(strend - scan); + s->match_length = MAX_MATCH - (uInt)(strend - scan); if (s->match_length > s->lookahead) s->match_length = s->lookahead; } diff --git a/contrib/zlib/deflate.h b/contrib/zlib/deflate.h index ce0299e..23ecdd3 100644 --- a/contrib/zlib/deflate.h +++ b/contrib/zlib/deflate.h @@ -1,5 +1,5 @@ /* deflate.h -- internal compression state - * Copyright (C) 1995-2012 Jean-loup Gailly + * Copyright (C) 1995-2016 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -51,13 +51,16 @@ #define Buf_size 16 /* size of bit buffer in bi_buf */ -#define INIT_STATE 42 -#define EXTRA_STATE 69 -#define NAME_STATE 73 -#define COMMENT_STATE 91 -#define HCRC_STATE 103 -#define BUSY_STATE 113 -#define FINISH_STATE 666 +#define INIT_STATE 42 /* zlib header -> BUSY_STATE */ +#ifdef GZIP +# define GZIP_STATE 57 /* gzip header -> BUSY_STATE | EXTRA_STATE */ +#endif +#define EXTRA_STATE 69 /* gzip extra block -> NAME_STATE */ +#define NAME_STATE 73 /* gzip file name -> COMMENT_STATE */ +#define COMMENT_STATE 91 /* gzip comment -> HCRC_STATE */ +#define HCRC_STATE 103 /* gzip header CRC -> BUSY_STATE */ +#define BUSY_STATE 113 /* deflate -> FINISH_STATE */ +#define FINISH_STATE 666 /* stream complete */ /* Stream status */ @@ -83,7 +86,7 @@ typedef struct static_tree_desc_s static_tree_desc; typedef struct tree_desc_s { ct_data *dyn_tree; /* the dynamic tree */ int max_code; /* largest code with non zero frequency */ - static_tree_desc *stat_desc; /* the corresponding static tree */ + const static_tree_desc *stat_desc; /* the corresponding static tree */ } FAR tree_desc; typedef ush Pos; @@ -100,10 +103,10 @@ typedef struct internal_state { Bytef *pending_buf; /* output still pending */ ulg pending_buf_size; /* size of pending_buf */ Bytef *pending_out; /* next pending byte to output to the stream */ - uInt pending; /* nb of bytes in the pending buffer */ + ulg pending; /* nb of bytes in the pending buffer */ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ gz_headerp gzhead; /* gzip header information to write */ - uInt gzindex; /* where in extra, name, or comment */ + ulg gzindex; /* where in extra, name, or comment */ Byte method; /* can only be DEFLATED */ int last_flush; /* value of flush param for previous deflate call */ @@ -249,7 +252,7 @@ typedef struct internal_state { uInt matches; /* number of string matches in current block */ uInt insert; /* bytes at end of window left to insert */ -#ifdef DEBUG +#ifdef ZLIB_DEBUG ulg compressed_len; /* total bit length of compressed file mod 2^32 */ ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ #endif @@ -275,7 +278,7 @@ typedef struct internal_state { /* Output a byte on the stream. * IN assertion: there is enough room in pending_buf. */ -#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} +#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);} #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) @@ -309,7 +312,7 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, * used. */ -#ifndef DEBUG +#ifndef ZLIB_DEBUG /* Inline versions of _tr_tally for speed: */ #if defined(GEN_TREES_H) || !defined(STDC) @@ -328,8 +331,8 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, flush = (s->last_lit == s->lit_bufsize-1); \ } # define _tr_tally_dist(s, distance, length, flush) \ - { uch len = (length); \ - ush dist = (distance); \ + { uch len = (uch)(length); \ + ush dist = (ush)(distance); \ s->d_buf[s->last_lit] = dist; \ s->l_buf[s->last_lit++] = len; \ dist--; \ diff --git a/contrib/zlib/gzguts.h b/contrib/zlib/gzguts.h index d87659d..990a4d2 100644 --- a/contrib/zlib/gzguts.h +++ b/contrib/zlib/gzguts.h @@ -1,5 +1,5 @@ /* gzguts.h -- zlib internal header definitions for gz* operations - * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler + * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -25,6 +25,10 @@ # include # include #endif + +#ifndef _POSIX_SOURCE +# define _POSIX_SOURCE +#endif #include #ifdef _WIN32 @@ -35,6 +39,10 @@ # include #endif +#if defined(_WIN32) || defined(__CYGWIN__) +# define WIDECHAR +#endif + #ifdef WINAPI_FAMILY # define open _open # define read _read @@ -95,18 +103,19 @@ # endif #endif -/* unlike snprintf (which is required in C99, yet still not supported by - Microsoft more than a decade later!), _snprintf does not guarantee null - termination of the result -- however this is only used in gzlib.c where +/* unlike snprintf (which is required in C99), _snprintf does not guarantee + null termination of the result -- however this is only used in gzlib.c where the result is assured to fit in the space provided */ -#ifdef _MSC_VER +#if defined(_MSC_VER) && _MSC_VER < 1900 # define snprintf _snprintf #endif #ifndef local # define local static #endif -/* compile with -Dlocal if your debugger can't find static symbols */ +/* since "static" is used to mean two completely different things in C, we + define "local" for the non-static meaning of "static", for readability + (compile with -Dlocal if your debugger can't find static symbols) */ /* gz* functions always use library allocation functions */ #ifndef STDC @@ -170,7 +179,7 @@ typedef struct { char *path; /* path or fd for error messages */ unsigned size; /* buffer size, zero if not allocated yet */ unsigned want; /* requested buffer size, default is GZBUFSIZE */ - unsigned char *in; /* input buffer */ + unsigned char *in; /* input buffer (double-sized when writing) */ unsigned char *out; /* output buffer (double-sized when reading) */ int direct; /* 0 if processing gzip, 1 if transparent */ /* just for reading */ diff --git a/contrib/zlib/gzlib.c b/contrib/zlib/gzlib.c index d8dbb7e..b4cb5e4 100644 --- a/contrib/zlib/gzlib.c +++ b/contrib/zlib/gzlib.c @@ -1,5 +1,5 @@ /* gzlib.c -- zlib functions common to reading and writing gzip files - * Copyright (C) 2004, 2010, 2011, 2012, 2013 Mark Adler + * Copyright (C) 2004-2017 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -8,7 +8,7 @@ #include "gzguts.h" #include "zutil.h" -#if defined(_WIN32) && !defined(__BORLANDC__) +#if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__) # define LSEEK _lseeki64 #else #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 @@ -97,7 +97,7 @@ local gzFile gz_open(path, fd, mode) const char *mode; { gz_statep state; - size_t len; + z_size_t len; int oflag; #ifdef O_CLOEXEC int cloexec = 0; @@ -191,10 +191,10 @@ local gzFile gz_open(path, fd, mode) } /* save the path name for error messages */ -#ifdef _WIN32 +#ifdef WIDECHAR if (fd == -2) { len = wcstombs(NULL, path, 0); - if (len == (size_t)-1) + if (len == (z_size_t)-1) len = 0; } else @@ -205,7 +205,7 @@ local gzFile gz_open(path, fd, mode) free(state); return NULL; } -#ifdef _WIN32 +#ifdef WIDECHAR if (fd == -2) if (len) wcstombs(state->path, path, len + 1); @@ -214,7 +214,7 @@ local gzFile gz_open(path, fd, mode) else #endif #if !defined(NO_snprintf) && !defined(NO_vsnprintf) - snprintf(state->path, len + 1, "%s", (const char *)path); + (void)snprintf(state->path, len + 1, "%s", (const char *)path); #else strcpy(state->path, path); #endif @@ -242,7 +242,7 @@ local gzFile gz_open(path, fd, mode) /* open the file with the appropriate flags (or just use fd) */ state->fd = fd > -1 ? fd : ( -#ifdef _WIN32 +#ifdef WIDECHAR fd == -2 ? _wopen(path, oflag, 0666) : #endif open((const char *)path, oflag, 0666)); @@ -251,8 +251,10 @@ local gzFile gz_open(path, fd, mode) free(state); return NULL; } - if (state->mode == GZ_APPEND) + if (state->mode == GZ_APPEND) { + LSEEK(state->fd, 0, SEEK_END); /* so gzoffset() is correct */ state->mode = GZ_WRITE; /* simplify later checks */ + } /* save the current position for rewinding (only if reading) */ if (state->mode == GZ_READ) { @@ -294,7 +296,7 @@ gzFile ZEXPORT gzdopen(fd, mode) if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL) return NULL; #if !defined(NO_snprintf) && !defined(NO_vsnprintf) - snprintf(path, 7 + 3 * sizeof(int), "", fd); /* for debugging */ + (void)snprintf(path, 7 + 3 * sizeof(int), "", fd); #else sprintf(path, "", fd); /* for debugging */ #endif @@ -304,7 +306,7 @@ gzFile ZEXPORT gzdopen(fd, mode) } /* -- see zlib.h -- */ -#ifdef _WIN32 +#ifdef WIDECHAR gzFile ZEXPORT gzopen_w(path, mode) const wchar_t *path; const char *mode; @@ -332,6 +334,8 @@ int ZEXPORT gzbuffer(file, size) return -1; /* check and set requested size */ + if ((size << 1) < size) + return -1; /* need to be able to double it */ if (size < 2) size = 2; /* need two bytes to check magic header */ state->want = size; @@ -607,14 +611,13 @@ void ZLIB_INTERNAL gz_error(state, err, msg) return; } #if !defined(NO_snprintf) && !defined(NO_vsnprintf) - snprintf(state->msg, strlen(state->path) + strlen(msg) + 3, - "%s%s%s", state->path, ": ", msg); + (void)snprintf(state->msg, strlen(state->path) + strlen(msg) + 3, + "%s%s%s", state->path, ": ", msg); #else strcpy(state->msg, state->path); strcat(state->msg, ": "); strcat(state->msg, msg); #endif - return; } #ifndef INT_MAX diff --git a/contrib/zlib/gzread.c b/contrib/zlib/gzread.c index a8292ea..1ba184f 100644 --- a/contrib/zlib/gzread.c +++ b/contrib/zlib/gzread.c @@ -1,5 +1,5 @@ /* gzread.c -- zlib functions for reading gzip files - * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler + * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -15,6 +15,7 @@ local int gz_look OF((gz_statep)); local int gz_decomp OF((gz_statep)); local int gz_fetch OF((gz_statep)); local int gz_skip OF((gz_statep, z_off64_t)); +local z_size_t gz_read OF((gz_statep, voidp, z_size_t)); /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from state->fd, and update state->eof, state->err, and state->msg as appropriate. @@ -27,13 +28,17 @@ local int gz_load(state, buf, len, have) unsigned *have; { int ret; + unsigned get, max = ((unsigned)-1 >> 2) + 1; *have = 0; do { - ret = read(state->fd, buf + *have, len - *have); + get = len - *have; + if (get > max) + get = max; + ret = read(state->fd, buf + *have, get); if (ret <= 0) break; - *have += ret; + *have += (unsigned)ret; } while (*have < len); if (ret < 0) { gz_error(state, Z_ERRNO, zstrerror()); @@ -97,10 +102,8 @@ local int gz_look(state) state->in = (unsigned char *)malloc(state->want); state->out = (unsigned char *)malloc(state->want << 1); if (state->in == NULL || state->out == NULL) { - if (state->out != NULL) - free(state->out); - if (state->in != NULL) - free(state->in); + free(state->out); + free(state->in); gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; } @@ -287,33 +290,17 @@ local int gz_skip(state, len) return 0; } -/* -- see zlib.h -- */ -int ZEXPORT gzread(file, buf, len) - gzFile file; +/* Read len bytes into buf from file, or less than len up to the end of the + input. Return the number of bytes read. If zero is returned, either the + end of file was reached, or there was an error. state->err must be + consulted in that case to determine which. */ +local z_size_t gz_read(state, buf, len) + gz_statep state; voidp buf; - unsigned len; + z_size_t len; { - unsigned got, n; - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return -1; - - /* since an int is returned, make sure len fits in one, otherwise return - with an error (this avoids the flaw in the interface) */ - if ((int)len < 0) { - gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); - return -1; - } + z_size_t got; + unsigned n; /* if len is zero, avoid unnecessary operations */ if (len == 0) @@ -323,32 +310,38 @@ int ZEXPORT gzread(file, buf, len) if (state->seek) { state->seek = 0; if (gz_skip(state, state->skip) == -1) - return -1; + return 0; } /* get len bytes to buf, or less than len if at the end */ got = 0; do { + /* set n to the maximum amount of len that fits in an unsigned int */ + n = -1; + if (n > len) + n = len; + /* first just try copying data from the output buffer */ if (state->x.have) { - n = state->x.have > len ? len : state->x.have; + if (state->x.have < n) + n = state->x.have; memcpy(buf, state->x.next, n); state->x.next += n; state->x.have -= n; } /* output buffer empty -- return if we're at the end of the input */ - else if (state->eof && strm->avail_in == 0) { + else if (state->eof && state->strm.avail_in == 0) { state->past = 1; /* tried to read past end */ break; } /* need output data -- for small len or new stream load up our output buffer */ - else if (state->how == LOOK || len < (state->size << 1)) { + else if (state->how == LOOK || n < (state->size << 1)) { /* get more output, looking for header if required */ if (gz_fetch(state) == -1) - return -1; + return 0; continue; /* no progress yet -- go back to copy above */ /* the copy above assures that we will leave with space in the output buffer, allowing at least one gzungetc() to succeed */ @@ -356,16 +349,16 @@ int ZEXPORT gzread(file, buf, len) /* large len -- read directly into user buffer */ else if (state->how == COPY) { /* read directly */ - if (gz_load(state, (unsigned char *)buf, len, &n) == -1) - return -1; + if (gz_load(state, (unsigned char *)buf, n, &n) == -1) + return 0; } /* large len -- decompress directly into user buffer */ else { /* state->how == GZIP */ - strm->avail_out = len; - strm->next_out = (unsigned char *)buf; + state->strm.avail_out = n; + state->strm.next_out = (unsigned char *)buf; if (gz_decomp(state) == -1) - return -1; + return 0; n = state->x.have; state->x.have = 0; } @@ -377,8 +370,75 @@ int ZEXPORT gzread(file, buf, len) state->x.pos += n; } while (len); - /* return number of bytes read into user buffer (will fit in int) */ - return (int)got; + /* return number of bytes read into user buffer */ + return got; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzread(file, buf, len) + gzFile file; + voidp buf; + unsigned len; +{ + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + + /* check that we're reading and that there's no (serious) error */ + if (state->mode != GZ_READ || + (state->err != Z_OK && state->err != Z_BUF_ERROR)) + return -1; + + /* since an int is returned, make sure len fits in one, otherwise return + with an error (this avoids a flaw in the interface) */ + if ((int)len < 0) { + gz_error(state, Z_STREAM_ERROR, "request does not fit in an int"); + return -1; + } + + /* read len or fewer bytes to buf */ + len = gz_read(state, buf, len); + + /* check for an error */ + if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR) + return -1; + + /* return the number of bytes read (this is assured to fit in an int) */ + return (int)len; +} + +/* -- see zlib.h -- */ +z_size_t ZEXPORT gzfread(buf, size, nitems, file) + voidp buf; + z_size_t size; + z_size_t nitems; + gzFile file; +{ + z_size_t len; + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return 0; + state = (gz_statep)file; + + /* check that we're reading and that there's no (serious) error */ + if (state->mode != GZ_READ || + (state->err != Z_OK && state->err != Z_BUF_ERROR)) + return 0; + + /* compute bytes to read -- error on overflow */ + len = nitems * size; + if (size && len / size != nitems) { + gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); + return 0; + } + + /* read len or fewer bytes to buf, return the number of full items read */ + return len ? gz_read(state, buf, len) / size : 0; } /* -- see zlib.h -- */ @@ -411,8 +471,8 @@ int ZEXPORT gzgetc(file) return *(state->x.next)++; } - /* nothing there -- try gzread() */ - ret = gzread(file, buf, 1); + /* nothing there -- try gz_read() */ + ret = gz_read(state, buf, 1); return ret < 1 ? -1 : buf[0]; } @@ -454,7 +514,7 @@ int ZEXPORT gzungetc(c, file) if (state->x.have == 0) { state->x.have = 1; state->x.next = state->out + (state->size << 1) - 1; - state->x.next[0] = c; + state->x.next[0] = (unsigned char)c; state->x.pos--; state->past = 0; return c; @@ -476,7 +536,7 @@ int ZEXPORT gzungetc(c, file) } state->x.have++; state->x.next--; - state->x.next[0] = c; + state->x.next[0] = (unsigned char)c; state->x.pos--; state->past = 0; return c; diff --git a/contrib/zlib/gzwrite.c b/contrib/zlib/gzwrite.c index 99cb3c2..8b38834 100644 --- a/contrib/zlib/gzwrite.c +++ b/contrib/zlib/gzwrite.c @@ -1,5 +1,5 @@ /* gzwrite.c -- zlib functions for writing gzip files - * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler + * Copyright (C) 2004-2017 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -12,17 +12,19 @@ local int gz_init OF((gz_statep)); local int gz_comp OF((gz_statep, int)); local int gz_zero OF((gz_statep, z_off64_t)); +local z_size_t gz_write OF((gz_statep, voidpc, z_size_t)); /* Initialize state for writing a gzip file. Mark initialization by setting - state->size to non-zero. Return -1 on failure or 0 on success. */ + state->size to non-zero. Return -1 on a memory allocation failure, or 0 on + success. */ local int gz_init(state) gz_statep state; { int ret; z_streamp strm = &(state->strm); - /* allocate input buffer */ - state->in = (unsigned char *)malloc(state->want); + /* allocate input buffer (double size for gzprintf) */ + state->in = (unsigned char *)malloc(state->want << 1); if (state->in == NULL) { gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; @@ -50,6 +52,7 @@ local int gz_init(state) gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; } + strm->next_in = NULL; } /* mark state as initialized */ @@ -65,17 +68,17 @@ local int gz_init(state) } /* Compress whatever is at avail_in and next_in and write to the output file. - Return -1 if there is an error writing to the output file, otherwise 0. - flush is assumed to be a valid deflate() flush value. If flush is Z_FINISH, - then the deflate() state is reset to start a new gzip stream. If gz->direct - is true, then simply write to the output file without compressing, and - ignore flush. */ + Return -1 if there is an error writing to the output file or if gz_init() + fails to allocate memory, otherwise 0. flush is assumed to be a valid + deflate() flush value. If flush is Z_FINISH, then the deflate() state is + reset to start a new gzip stream. If gz->direct is true, then simply write + to the output file without compressing, and ignore flush. */ local int gz_comp(state, flush) gz_statep state; int flush; { - int ret, got; - unsigned have; + int ret, writ; + unsigned have, put, max = ((unsigned)-1 >> 2) + 1; z_streamp strm = &(state->strm); /* allocate memory if this is the first time through */ @@ -84,12 +87,16 @@ local int gz_comp(state, flush) /* write directly if requested */ if (state->direct) { - got = write(state->fd, strm->next_in, strm->avail_in); - if (got < 0 || (unsigned)got != strm->avail_in) { - gz_error(state, Z_ERRNO, zstrerror()); - return -1; + while (strm->avail_in) { + put = strm->avail_in > max ? max : strm->avail_in; + writ = write(state->fd, strm->next_in, put); + if (writ < 0) { + gz_error(state, Z_ERRNO, zstrerror()); + return -1; + } + strm->avail_in -= (unsigned)writ; + strm->next_in += writ; } - strm->avail_in = 0; return 0; } @@ -100,17 +107,21 @@ local int gz_comp(state, flush) doing Z_FINISH then don't write until we get to Z_STREAM_END */ if (strm->avail_out == 0 || (flush != Z_NO_FLUSH && (flush != Z_FINISH || ret == Z_STREAM_END))) { - have = (unsigned)(strm->next_out - state->x.next); - if (have && ((got = write(state->fd, state->x.next, have)) < 0 || - (unsigned)got != have)) { - gz_error(state, Z_ERRNO, zstrerror()); - return -1; + while (strm->next_out > state->x.next) { + put = strm->next_out - state->x.next > (int)max ? max : + (unsigned)(strm->next_out - state->x.next); + writ = write(state->fd, state->x.next, put); + if (writ < 0) { + gz_error(state, Z_ERRNO, zstrerror()); + return -1; + } + state->x.next += writ; } if (strm->avail_out == 0) { strm->avail_out = state->size; strm->next_out = state->out; + state->x.next = state->out; } - state->x.next = strm->next_out; } /* compress */ @@ -132,7 +143,8 @@ local int gz_comp(state, flush) return 0; } -/* Compress len zeros to output. Return -1 on error, 0 on success. */ +/* Compress len zeros to output. Return -1 on a write error or memory + allocation failure by gz_comp(), or 0 on success. */ local int gz_zero(state, len) gz_statep state; z_off64_t len; @@ -164,32 +176,14 @@ local int gz_zero(state, len) return 0; } -/* -- see zlib.h -- */ -int ZEXPORT gzwrite(file, buf, len) - gzFile file; +/* Write len bytes from buf to file. Return the number of bytes written. If + the returned value is less than len, then there was an error. */ +local z_size_t gz_write(state, buf, len) + gz_statep state; voidpc buf; - unsigned len; + z_size_t len; { - unsigned put = len; - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return 0; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return 0; - - /* since an int is returned, make sure len fits in one, otherwise return - with an error (this avoids the flaw in the interface) */ - if ((int)len < 0) { - gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); - return 0; - } + z_size_t put = len; /* if len is zero, avoid unnecessary operations */ if (len == 0) @@ -212,14 +206,15 @@ int ZEXPORT gzwrite(file, buf, len) do { unsigned have, copy; - if (strm->avail_in == 0) - strm->next_in = state->in; - have = (unsigned)((strm->next_in + strm->avail_in) - state->in); + if (state->strm.avail_in == 0) + state->strm.next_in = state->in; + have = (unsigned)((state->strm.next_in + state->strm.avail_in) - + state->in); copy = state->size - have; if (copy > len) copy = len; memcpy(state->in + have, buf, copy); - strm->avail_in += copy; + state->strm.avail_in += copy; state->x.pos += copy; buf = (const char *)buf + copy; len -= copy; @@ -229,19 +224,83 @@ int ZEXPORT gzwrite(file, buf, len) } else { /* consume whatever's left in the input buffer */ - if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) + if (state->strm.avail_in && gz_comp(state, Z_NO_FLUSH) == -1) return 0; /* directly compress user buffer to file */ - strm->avail_in = len; - strm->next_in = (z_const Bytef *)buf; - state->x.pos += len; - if (gz_comp(state, Z_NO_FLUSH) == -1) - return 0; + state->strm.next_in = (z_const Bytef *)buf; + do { + unsigned n = (unsigned)-1; + if (n > len) + n = len; + state->strm.avail_in = n; + state->x.pos += n; + if (gz_comp(state, Z_NO_FLUSH) == -1) + return 0; + len -= n; + } while (len); + } + + /* input was all buffered or compressed */ + return put; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzwrite(file, buf, len) + gzFile file; + voidpc buf; + unsigned len; +{ + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return 0; + state = (gz_statep)file; + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return 0; + + /* since an int is returned, make sure len fits in one, otherwise return + with an error (this avoids a flaw in the interface) */ + if ((int)len < 0) { + gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); + return 0; + } + + /* write len bytes from buf (the return value will fit in an int) */ + return (int)gz_write(state, buf, len); +} + +/* -- see zlib.h -- */ +z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) + voidpc buf; + z_size_t size; + z_size_t nitems; + gzFile file; +{ + z_size_t len; + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return 0; + state = (gz_statep)file; + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return 0; + + /* compute bytes to read -- error on overflow */ + len = nitems * size; + if (size && len / size != nitems) { + gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); + return 0; } - /* input was all buffered or compressed (put will fit in int) */ - return (int)put; + /* write len bytes to buf, return the number of full items written */ + return len ? gz_write(state, buf, len) / size : 0; } /* -- see zlib.h -- */ @@ -278,7 +337,7 @@ int ZEXPORT gzputc(file, c) strm->next_in = state->in; have = (unsigned)((strm->next_in + strm->avail_in) - state->in); if (have < state->size) { - state->in[have] = c; + state->in[have] = (unsigned char)c; strm->avail_in++; state->x.pos++; return c & 0xff; @@ -286,8 +345,8 @@ int ZEXPORT gzputc(file, c) } /* no room in buffer or not initialized, use gz_write() */ - buf[0] = c; - if (gzwrite(file, buf, 1) != 1) + buf[0] = (unsigned char)c; + if (gz_write(state, buf, 1) != 1) return -1; return c & 0xff; } @@ -298,11 +357,21 @@ int ZEXPORT gzputs(file, str) const char *str; { int ret; - unsigned len; + z_size_t len; + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return -1; /* write string */ - len = (unsigned)strlen(str); - ret = gzwrite(file, str, len); + len = strlen(str); + ret = gz_write(state, str, len); return ret == 0 && len != 0 ? -1 : ret; } @@ -312,63 +381,73 @@ int ZEXPORT gzputs(file, str) /* -- see zlib.h -- */ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) { - int size, len; + int len; + unsigned left; + char *next; gz_statep state; z_streamp strm; /* get internal structure */ if (file == NULL) - return -1; + return Z_STREAM_ERROR; state = (gz_statep)file; strm = &(state->strm); /* check that we're writing and that there's no error */ if (state->mode != GZ_WRITE || state->err != Z_OK) - return 0; + return Z_STREAM_ERROR; /* make sure we have some buffer space */ if (state->size == 0 && gz_init(state) == -1) - return 0; + return state->err; /* check for seek request */ if (state->seek) { state->seek = 0; if (gz_zero(state, state->skip) == -1) - return 0; + return state->err; } - /* consume whatever's left in the input buffer */ - if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) - return 0; - - /* do the printf() into the input buffer, put length in len */ - size = (int)(state->size); - state->in[size - 1] = 0; + /* do the printf() into the input buffer, put length in len -- the input + buffer is double-sized just for this function, so there is guaranteed to + be state->size bytes available after the current contents */ + if (strm->avail_in == 0) + strm->next_in = state->in; + next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in); + next[state->size - 1] = 0; #ifdef NO_vsnprintf # ifdef HAS_vsprintf_void - (void)vsprintf((char *)(state->in), format, va); - for (len = 0; len < size; len++) - if (state->in[len] == 0) break; + (void)vsprintf(next, format, va); + for (len = 0; len < state->size; len++) + if (next[len] == 0) break; # else - len = vsprintf((char *)(state->in), format, va); + len = vsprintf(next, format, va); # endif #else # ifdef HAS_vsnprintf_void - (void)vsnprintf((char *)(state->in), size, format, va); - len = strlen((char *)(state->in)); + (void)vsnprintf(next, state->size, format, va); + len = strlen(next); # else - len = vsnprintf((char *)(state->in), size, format, va); + len = vsnprintf(next, state->size, format, va); # endif #endif /* check that printf() results fit in buffer */ - if (len <= 0 || len >= (int)size || state->in[size - 1] != 0) + if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0) return 0; - /* update buffer and position, defer compression until needed */ - strm->avail_in = (unsigned)len; - strm->next_in = state->in; + /* update buffer and position, compress first half if past that */ + strm->avail_in += (unsigned)len; state->x.pos += len; + if (strm->avail_in >= state->size) { + left = strm->avail_in - state->size; + strm->avail_in = state->size; + if (gz_comp(state, Z_NO_FLUSH) == -1) + return state->err; + memcpy(state->in, state->in + state->size, left); + strm->next_in = state->in; + strm->avail_in = left; + } return len; } @@ -393,73 +472,82 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; { - int size, len; + unsigned len, left; + char *next; gz_statep state; z_streamp strm; /* get internal structure */ if (file == NULL) - return -1; + return Z_STREAM_ERROR; state = (gz_statep)file; strm = &(state->strm); /* check that can really pass pointer in ints */ if (sizeof(int) != sizeof(void *)) - return 0; + return Z_STREAM_ERROR; /* check that we're writing and that there's no error */ if (state->mode != GZ_WRITE || state->err != Z_OK) - return 0; + return Z_STREAM_ERROR; /* make sure we have some buffer space */ if (state->size == 0 && gz_init(state) == -1) - return 0; + return state->error; /* check for seek request */ if (state->seek) { state->seek = 0; if (gz_zero(state, state->skip) == -1) - return 0; + return state->error; } - /* consume whatever's left in the input buffer */ - if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) - return 0; - - /* do the printf() into the input buffer, put length in len */ - size = (int)(state->size); - state->in[size - 1] = 0; + /* do the printf() into the input buffer, put length in len -- the input + buffer is double-sized just for this function, so there is guaranteed to + be state->size bytes available after the current contents */ + if (strm->avail_in == 0) + strm->next_in = state->in; + next = (char *)(strm->next_in + strm->avail_in); + next[state->size - 1] = 0; #ifdef NO_snprintf # ifdef HAS_sprintf_void - sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, + a13, a14, a15, a16, a17, a18, a19, a20); for (len = 0; len < size; len++) - if (state->in[len] == 0) break; + if (next[len] == 0) + break; # else - len = sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + len = sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, + a12, a13, a14, a15, a16, a17, a18, a19, a20); # endif #else # ifdef HAS_snprintf_void - snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); - len = strlen((char *)(state->in)); + snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, + a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + len = strlen(next); # else - len = snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, - a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, - a19, a20); + len = snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); # endif #endif /* check that printf() results fit in buffer */ - if (len <= 0 || len >= (int)size || state->in[size - 1] != 0) + if (len == 0 || len >= state->size || next[state->size - 1] != 0) return 0; - /* update buffer and position, defer compression until needed */ - strm->avail_in = (unsigned)len; - strm->next_in = state->in; + /* update buffer and position, compress first half if past that */ + strm->avail_in += len; state->x.pos += len; - return len; + if (strm->avail_in >= state->size) { + left = strm->avail_in - state->size; + strm->avail_in = state->size; + if (gz_comp(state, Z_NO_FLUSH) == -1) + return state->err; + memcpy(state->in, state->in + state->size, left); + strm->next_in = state->in; + strm->avail_in = left; + } + return (int)len; } #endif @@ -473,7 +561,7 @@ int ZEXPORT gzflush(file, flush) /* get internal structure */ if (file == NULL) - return -1; + return Z_STREAM_ERROR; state = (gz_statep)file; /* check that we're writing and that there's no error */ @@ -488,11 +576,11 @@ int ZEXPORT gzflush(file, flush) if (state->seek) { state->seek = 0; if (gz_zero(state, state->skip) == -1) - return -1; + return state->err; } /* compress remaining data with requested flush */ - gz_comp(state, flush); + (void)gz_comp(state, flush); return state->err; } @@ -523,13 +611,13 @@ int ZEXPORT gzsetparams(file, level, strategy) if (state->seek) { state->seek = 0; if (gz_zero(state, state->skip) == -1) - return -1; + return state->err; } /* change compression parameters for subsequent input */ if (state->size) { /* flush previous input with previous parameters before changing */ - if (strm->avail_in && gz_comp(state, Z_PARTIAL_FLUSH) == -1) + if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1) return state->err; deflateParams(strm, level, strategy); } diff --git a/contrib/zlib/infback.c b/contrib/zlib/infback.c index f3833c2..59679ec 100644 --- a/contrib/zlib/infback.c +++ b/contrib/zlib/infback.c @@ -1,5 +1,5 @@ /* infback.c -- inflate using a call-back interface - * Copyright (C) 1995-2011 Mark Adler + * Copyright (C) 1995-2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -61,7 +61,7 @@ int stream_size; Tracev((stderr, "inflate: allocated\n")); strm->state = (struct internal_state FAR *)state; state->dmax = 32768U; - state->wbits = windowBits; + state->wbits = (uInt)windowBits; state->wsize = 1U << windowBits; state->window = window; state->wnext = 0; diff --git a/contrib/zlib/inffast.c b/contrib/zlib/inffast.c index bda59ce..0dbd1db 100644 --- a/contrib/zlib/inffast.c +++ b/contrib/zlib/inffast.c @@ -1,5 +1,5 @@ /* inffast.c -- fast decoding - * Copyright (C) 1995-2008, 2010, 2013 Mark Adler + * Copyright (C) 1995-2017 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -8,26 +8,9 @@ #include "inflate.h" #include "inffast.h" -#ifndef ASMINF - -/* Allow machine dependent optimization for post-increment or pre-increment. - Based on testing to date, - Pre-increment preferred for: - - PowerPC G3 (Adler) - - MIPS R5000 (Randers-Pehrson) - Post-increment preferred for: - - none - No measurable difference: - - Pentium III (Anderson) - - M68060 (Nikl) - */ -#ifdef POSTINC -# define OFF 0 -# define PUP(a) *(a)++ +#ifdef ASMINF +# pragma message("Assembler code may have bugs -- use at your own risk") #else -# define OFF 1 -# define PUP(a) *++(a) -#endif /* Decode literal, length, and distance codes and write out the resulting @@ -96,9 +79,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ /* copy state to local variables */ state = (struct inflate_state FAR *)strm->state; - in = strm->next_in - OFF; + in = strm->next_in; last = in + (strm->avail_in - 5); - out = strm->next_out - OFF; + out = strm->next_out; beg = out - (start - strm->avail_out); end = out + (strm->avail_out - 257); #ifdef INFLATE_STRICT @@ -119,9 +102,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ input data or output space */ do { if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; } here = lcode[hold & lmask]; @@ -134,14 +117,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? "inflate: literal '%c'\n" : "inflate: literal 0x%02x\n", here.val)); - PUP(out) = (unsigned char)(here.val); + *out++ = (unsigned char)(here.val); } else if (op & 16) { /* length base */ len = (unsigned)(here.val); op &= 15; /* number of extra bits */ if (op) { if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; } len += (unsigned)hold & ((1U << op) - 1); @@ -150,9 +133,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ } Tracevv((stderr, "inflate: length %u\n", len)); if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; } here = dcode[hold & dmask]; @@ -165,10 +148,10 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ dist = (unsigned)(here.val); op &= 15; /* number of extra bits */ if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; } } @@ -196,30 +179,30 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR if (len <= op - whave) { do { - PUP(out) = 0; + *out++ = 0; } while (--len); continue; } len -= op - whave; do { - PUP(out) = 0; + *out++ = 0; } while (--op > whave); if (op == 0) { from = out - dist; do { - PUP(out) = PUP(from); + *out++ = *from++; } while (--len); continue; } #endif } - from = window - OFF; + from = window; if (wnext == 0) { /* very common case */ from += wsize - op; if (op < len) { /* some from window */ len -= op; do { - PUP(out) = PUP(from); + *out++ = *from++; } while (--op); from = out - dist; /* rest from output */ } @@ -230,14 +213,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ if (op < len) { /* some from end of window */ len -= op; do { - PUP(out) = PUP(from); + *out++ = *from++; } while (--op); - from = window - OFF; + from = window; if (wnext < len) { /* some from start of window */ op = wnext; len -= op; do { - PUP(out) = PUP(from); + *out++ = *from++; } while (--op); from = out - dist; /* rest from output */ } @@ -248,35 +231,35 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ if (op < len) { /* some from window */ len -= op; do { - PUP(out) = PUP(from); + *out++ = *from++; } while (--op); from = out - dist; /* rest from output */ } } while (len > 2) { - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); + *out++ = *from++; + *out++ = *from++; + *out++ = *from++; len -= 3; } if (len) { - PUP(out) = PUP(from); + *out++ = *from++; if (len > 1) - PUP(out) = PUP(from); + *out++ = *from++; } } else { from = out - dist; /* copy direct from output */ do { /* minimum length is three */ - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); + *out++ = *from++; + *out++ = *from++; + *out++ = *from++; len -= 3; } while (len > 2); if (len) { - PUP(out) = PUP(from); + *out++ = *from++; if (len > 1) - PUP(out) = PUP(from); + *out++ = *from++; } } } @@ -313,8 +296,8 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ hold &= (1U << bits) - 1; /* update state and return */ - strm->next_in = in + OFF; - strm->next_out = out + OFF; + strm->next_in = in; + strm->next_out = out; strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); strm->avail_out = (unsigned)(out < end ? 257 + (end - out) : 257 - (out - end)); diff --git a/contrib/zlib/inflate.c b/contrib/zlib/inflate.c index b51a8a5..ac333e8 100644 --- a/contrib/zlib/inflate.c +++ b/contrib/zlib/inflate.c @@ -1,5 +1,5 @@ /* inflate.c -- zlib decompression - * Copyright (C) 1995-2012 Mark Adler + * Copyright (C) 1995-2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -92,6 +92,7 @@ #endif /* function prototypes */ +local int inflateStateCheck OF((z_streamp strm)); local void fixedtables OF((struct inflate_state FAR *state)); local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, unsigned copy)); @@ -101,12 +102,26 @@ local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf, unsigned len)); +local int inflateStateCheck(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + if (strm == Z_NULL || + strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) + return 1; + state = (struct inflate_state FAR *)strm->state; + if (state == Z_NULL || state->strm != strm || + state->mode < HEAD || state->mode > SYNC) + return 1; + return 0; +} + int ZEXPORT inflateResetKeep(strm) z_streamp strm; { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; strm->total_in = strm->total_out = state->total = 0; strm->msg = Z_NULL; @@ -131,7 +146,7 @@ z_streamp strm; { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; state->wsize = 0; state->whave = 0; @@ -147,7 +162,7 @@ int windowBits; struct inflate_state FAR *state; /* get the state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; /* extract wrap request from windowBits parameter */ @@ -156,7 +171,7 @@ int windowBits; windowBits = -windowBits; } else { - wrap = (windowBits >> 4) + 1; + wrap = (windowBits >> 4) + 5; #ifdef GUNZIP if (windowBits < 48) windowBits &= 15; @@ -210,7 +225,9 @@ int stream_size; if (state == Z_NULL) return Z_MEM_ERROR; Tracev((stderr, "inflate: allocated\n")); strm->state = (struct internal_state FAR *)state; + state->strm = strm; state->window = Z_NULL; + state->mode = HEAD; /* to pass state test in inflateReset2() */ ret = inflateReset2(strm, windowBits); if (ret != Z_OK) { ZFREE(strm, state); @@ -234,17 +251,17 @@ int value; { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (bits < 0) { state->hold = 0; state->bits = 0; return Z_OK; } - if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; + if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR; value &= (1L << bits) - 1; - state->hold += value << state->bits; - state->bits += bits; + state->hold += (unsigned)value << state->bits; + state->bits += (uInt)bits; return Z_OK; } @@ -625,7 +642,7 @@ int flush; static const unsigned short order[19] = /* permutation of code lengths */ {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL || + if (inflateStateCheck(strm) || strm->next_out == Z_NULL || (strm->next_in == Z_NULL && strm->avail_in != 0)) return Z_STREAM_ERROR; @@ -645,6 +662,8 @@ int flush; NEEDBITS(16); #ifdef GUNZIP if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ + if (state->wbits == 0) + state->wbits = 15; state->check = crc32(0L, Z_NULL, 0); CRC2(state->check, hold); INITBITS(); @@ -672,7 +691,7 @@ int flush; len = BITS(4) + 8; if (state->wbits == 0) state->wbits = len; - else if (len > state->wbits) { + if (len > 15 || len > state->wbits) { strm->msg = (char *)"invalid window size"; state->mode = BAD; break; @@ -699,14 +718,16 @@ int flush; } if (state->head != Z_NULL) state->head->text = (int)((hold >> 8) & 1); - if (state->flags & 0x0200) CRC2(state->check, hold); + if ((state->flags & 0x0200) && (state->wrap & 4)) + CRC2(state->check, hold); INITBITS(); state->mode = TIME; case TIME: NEEDBITS(32); if (state->head != Z_NULL) state->head->time = hold; - if (state->flags & 0x0200) CRC4(state->check, hold); + if ((state->flags & 0x0200) && (state->wrap & 4)) + CRC4(state->check, hold); INITBITS(); state->mode = OS; case OS: @@ -715,7 +736,8 @@ int flush; state->head->xflags = (int)(hold & 0xff); state->head->os = (int)(hold >> 8); } - if (state->flags & 0x0200) CRC2(state->check, hold); + if ((state->flags & 0x0200) && (state->wrap & 4)) + CRC2(state->check, hold); INITBITS(); state->mode = EXLEN; case EXLEN: @@ -724,7 +746,8 @@ int flush; state->length = (unsigned)(hold); if (state->head != Z_NULL) state->head->extra_len = (unsigned)hold; - if (state->flags & 0x0200) CRC2(state->check, hold); + if ((state->flags & 0x0200) && (state->wrap & 4)) + CRC2(state->check, hold); INITBITS(); } else if (state->head != Z_NULL) @@ -742,7 +765,7 @@ int flush; len + copy > state->head->extra_max ? state->head->extra_max - len : copy); } - if (state->flags & 0x0200) + if ((state->flags & 0x0200) && (state->wrap & 4)) state->check = crc32(state->check, next, copy); have -= copy; next += copy; @@ -761,9 +784,9 @@ int flush; if (state->head != Z_NULL && state->head->name != Z_NULL && state->length < state->head->name_max) - state->head->name[state->length++] = len; + state->head->name[state->length++] = (Bytef)len; } while (len && copy < have); - if (state->flags & 0x0200) + if ((state->flags & 0x0200) && (state->wrap & 4)) state->check = crc32(state->check, next, copy); have -= copy; next += copy; @@ -782,9 +805,9 @@ int flush; if (state->head != Z_NULL && state->head->comment != Z_NULL && state->length < state->head->comm_max) - state->head->comment[state->length++] = len; + state->head->comment[state->length++] = (Bytef)len; } while (len && copy < have); - if (state->flags & 0x0200) + if ((state->flags & 0x0200) && (state->wrap & 4)) state->check = crc32(state->check, next, copy); have -= copy; next += copy; @@ -796,7 +819,7 @@ int flush; case HCRC: if (state->flags & 0x0200) { NEEDBITS(16); - if (hold != (state->check & 0xffff)) { + if ((state->wrap & 4) && hold != (state->check & 0xffff)) { strm->msg = (char *)"header crc mismatch"; state->mode = BAD; break; @@ -1177,11 +1200,11 @@ int flush; out -= left; strm->total_out += out; state->total += out; - if (out) + if ((state->wrap & 4) && out) strm->adler = state->check = UPDATE(state->check, put - out, out); out = left; - if (( + if ((state->wrap & 4) && ( #ifdef GUNZIP state->flags ? hold : #endif @@ -1240,10 +1263,10 @@ int flush; strm->total_in += in; strm->total_out += out; state->total += out; - if (state->wrap && out) + if ((state->wrap & 4) && out) strm->adler = state->check = UPDATE(state->check, strm->next_out - out, out); - strm->data_type = state->bits + (state->last ? 64 : 0) + + strm->data_type = (int)state->bits + (state->last ? 64 : 0) + (state->mode == TYPE ? 128 : 0) + (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0); if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) @@ -1255,7 +1278,7 @@ int ZEXPORT inflateEnd(strm) z_streamp strm; { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (state->window != Z_NULL) ZFREE(strm, state->window); @@ -1273,7 +1296,7 @@ uInt *dictLength; struct inflate_state FAR *state; /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; /* copy dictionary */ @@ -1298,7 +1321,7 @@ uInt dictLength; int ret; /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (state->wrap != 0 && state->mode != DICT) return Z_STREAM_ERROR; @@ -1330,7 +1353,7 @@ gz_headerp head; struct inflate_state FAR *state; /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; @@ -1383,7 +1406,7 @@ z_streamp strm; struct inflate_state FAR *state; /* check parameters */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; @@ -1430,7 +1453,7 @@ z_streamp strm; { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; return state->mode == STORED && state->bits == 0; } @@ -1445,8 +1468,7 @@ z_streamp source; unsigned wsize; /* check input */ - if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || - source->zalloc == (alloc_func)0 || source->zfree == (free_func)0) + if (inflateStateCheck(source) || dest == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)source->state; @@ -1467,6 +1489,7 @@ z_streamp source; /* copy state */ zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state)); + copy->strm = dest; if (state->lencode >= state->codes && state->lencode <= state->codes + ENOUGH - 1) { copy->lencode = copy->codes + (state->lencode - state->codes); @@ -1488,25 +1511,51 @@ int subvert; { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; - state->sane = !subvert; #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + state->sane = !subvert; return Z_OK; #else + (void)subvert; state->sane = 1; return Z_DATA_ERROR; #endif } +int ZEXPORT inflateValidate(strm, check) +z_streamp strm; +int check; +{ + struct inflate_state FAR *state; + + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (check) + state->wrap |= 4; + else + state->wrap &= ~4; + return Z_OK; +} + long ZEXPORT inflateMark(strm) z_streamp strm; { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL) return -(1L << 16); + if (inflateStateCheck(strm)) + return -(1L << 16); state = (struct inflate_state FAR *)strm->state; - return ((long)(state->back) << 16) + + return (long)(((unsigned long)((long)state->back)) << 16) + (state->mode == COPY ? state->length : (state->mode == MATCH ? state->was - state->length : 0)); } + +unsigned long ZEXPORT inflateCodesUsed(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + if (inflateStateCheck(strm)) return (unsigned long)-1; + state = (struct inflate_state FAR *)strm->state; + return (unsigned long)(state->next - state->codes); +} diff --git a/contrib/zlib/inflate.h b/contrib/zlib/inflate.h index 95f4986..a46cce6 100644 --- a/contrib/zlib/inflate.h +++ b/contrib/zlib/inflate.h @@ -1,5 +1,5 @@ /* inflate.h -- internal inflate state definition - * Copyright (C) 1995-2009 Mark Adler + * Copyright (C) 1995-2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -18,7 +18,7 @@ /* Possible inflate modes between inflate() calls */ typedef enum { - HEAD, /* i: waiting for magic header */ + HEAD = 16180, /* i: waiting for magic header */ FLAGS, /* i: waiting for method and flags (gzip) */ TIME, /* i: waiting for modification time (gzip) */ OS, /* i: waiting for extra flags and operating system (gzip) */ @@ -77,11 +77,14 @@ typedef enum { CHECK -> LENGTH -> DONE */ -/* state maintained between inflate() calls. Approximately 10K bytes. */ +/* State maintained between inflate() calls -- approximately 7K bytes, not + including the allocated sliding window, which is up to 32K bytes. */ struct inflate_state { + z_streamp strm; /* pointer back to this zlib stream */ inflate_mode mode; /* current inflate mode */ int last; /* true if processing last block */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip, + bit 2 true to validate check value */ int havedict; /* true if dictionary provided */ int flags; /* gzip header method and flags (0 if zlib) */ unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ diff --git a/contrib/zlib/inftrees.c b/contrib/zlib/inftrees.c index 44d89cf..2ea08fc 100644 --- a/contrib/zlib/inftrees.c +++ b/contrib/zlib/inftrees.c @@ -1,5 +1,5 @@ /* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2013 Mark Adler + * Copyright (C) 1995-2017 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,7 +9,7 @@ #define MAXBITS 15 const char inflate_copyright[] = - " inflate 1.2.8 Copyright 1995-2013 Mark Adler "; + " inflate 1.2.11 Copyright 1995-2017 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -54,7 +54,7 @@ unsigned short FAR *work; code FAR *next; /* next available space in table */ const unsigned short FAR *base; /* base value table to use */ const unsigned short FAR *extra; /* extra bits table to use */ - int end; /* use base and extra for symbol > end */ + unsigned match; /* use base and extra for symbol >= match */ unsigned short count[MAXBITS+1]; /* number of codes of each length */ unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ static const unsigned short lbase[31] = { /* Length codes 257..285 base */ @@ -62,7 +62,7 @@ unsigned short FAR *work; 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78}; + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202}; static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, @@ -181,19 +181,17 @@ unsigned short FAR *work; switch (type) { case CODES: base = extra = work; /* dummy value--not used */ - end = 19; + match = 20; break; case LENS: base = lbase; - base -= 257; extra = lext; - extra -= 257; - end = 256; + match = 257; break; - default: /* DISTS */ + default: /* DISTS */ base = dbase; extra = dext; - end = -1; + match = 0; } /* initialize state for loop */ @@ -216,13 +214,13 @@ unsigned short FAR *work; for (;;) { /* create table entry */ here.bits = (unsigned char)(len - drop); - if ((int)(work[sym]) < end) { + if (work[sym] + 1U < match) { here.op = (unsigned char)0; here.val = work[sym]; } - else if ((int)(work[sym]) > end) { - here.op = (unsigned char)(extra[work[sym]]); - here.val = base[work[sym]]; + else if (work[sym] >= match) { + here.op = (unsigned char)(extra[work[sym] - match]); + here.val = base[work[sym] - match]; } else { here.op = (unsigned char)(32 + 64); /* end of block */ diff --git a/contrib/zlib/test/example.c b/contrib/zlib/test/example.c index 138a699..eee17ce 100644 --- a/contrib/zlib/test/example.c +++ b/contrib/zlib/test/example.c @@ -1,5 +1,5 @@ /* example.c -- usage example of the zlib compression library - * Copyright (C) 1995-2006, 2011 Jean-loup Gailly. + * Copyright (C) 1995-2006, 2011, 2016 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -26,13 +26,13 @@ } \ } -z_const char hello[] = "hello, hello!"; +static z_const char hello[] = "hello, hello!"; /* "hello world" would be more standard, but the repeated "hello" * stresses the compression code better, sorry... */ -const char dictionary[] = "hello"; -uLong dictId; /* Adler32 value of the dictionary */ +static const char dictionary[] = "hello"; +static uLong dictId; /* Adler32 value of the dictionary */ void test_deflate OF((Byte *compr, uLong comprLen)); void test_inflate OF((Byte *compr, uLong comprLen, @@ -59,13 +59,13 @@ void *myalloc(q, n, m) void *q; unsigned n, m; { - q = Z_NULL; + (void)q; return calloc(n, m); } void myfree(void *q, void *p) { - q = Z_NULL; + (void)q; free(p); } @@ -432,7 +432,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen) d_stream.next_out = uncompr; d_stream.avail_out = (uInt)uncomprLen; - inflate(&d_stream, Z_NO_FLUSH); + err = inflate(&d_stream, Z_NO_FLUSH); CHECK_ERR(err, "inflate"); d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */ @@ -573,7 +573,8 @@ int main(argc, argv) } #ifdef Z_SOLO - argc = strlen(argv[0]); + (void)argc; + (void)argv; #else test_compress(compr, comprLen, uncompr, uncomprLen); diff --git a/contrib/zlib/test/infcover.c b/contrib/zlib/test/infcover.c index fe3d920..2be0164 100644 --- a/contrib/zlib/test/infcover.c +++ b/contrib/zlib/test/infcover.c @@ -1,5 +1,5 @@ /* infcover.c -- test zlib's inflate routines with full code coverage - * Copyright (C) 2011 Mark Adler + * Copyright (C) 2011, 2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -237,14 +237,14 @@ local void mem_done(z_stream *strm, char *prefix) /* Decode a hexadecimal string, set *len to length, in[] to the bytes. This decodes liberally, in that hex digits can be adjacent, in which case two in - a row writes a byte. Or they can delimited by any non-hex character, where - the delimiters are ignored except when a single hex digit is followed by a - delimiter in which case that single digit writes a byte. The returned - data is allocated and must eventually be freed. NULL is returned if out of - memory. If the length is not needed, then len can be NULL. */ + a row writes a byte. Or they can be delimited by any non-hex character, + where the delimiters are ignored except when a single hex digit is followed + by a delimiter, where that single digit writes a byte. The returned data is + allocated and must eventually be freed. NULL is returned if out of memory. + If the length is not needed, then len can be NULL. */ local unsigned char *h2b(const char *hex, unsigned *len) { - unsigned char *in; + unsigned char *in, *re; unsigned next, val; in = malloc((strlen(hex) + 1) >> 1); @@ -268,8 +268,8 @@ local unsigned char *h2b(const char *hex, unsigned *len) } while (*hex++); /* go through the loop with the terminating null */ if (len != NULL) *len = next; - in = reallocf(in, next); - return in; + re = realloc(in, next); + return re == NULL ? in : re; } /* generic inflate() run, where hex is the hexadecimal input data, what is the diff --git a/contrib/zlib/test/minigzip.c b/contrib/zlib/test/minigzip.c index b3025a4..e22fb08 100644 --- a/contrib/zlib/test/minigzip.c +++ b/contrib/zlib/test/minigzip.c @@ -1,5 +1,5 @@ /* minigzip.c -- simulate gzip using the zlib compression library - * Copyright (C) 1995-2006, 2010, 2011 Jean-loup Gailly. + * Copyright (C) 1995-2006, 2010, 2011, 2016 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -40,7 +40,7 @@ # define SET_BINARY_MODE(file) #endif -#ifdef _MSC_VER +#if defined(_MSC_VER) && _MSC_VER < 1900 # define snprintf _snprintf #endif @@ -156,14 +156,14 @@ void *myalloc(q, n, m) void *q; unsigned n, m; { - q = Z_NULL; + (void)q; return calloc(n, m); } void myfree(q, p) void *q, *p; { - q = Z_NULL; + (void)q; free(p); } @@ -333,7 +333,7 @@ const char *gzerror(gz, err) #endif -char *prog; +static char *prog; void error OF((const char *msg)); void gz_compress OF((FILE *in, gzFile out)); @@ -500,7 +500,7 @@ void file_uncompress(file) char *infile, *outfile; FILE *out; gzFile in; - size_t len = strlen(file); + unsigned len = strlen(file); if (len + strlen(GZ_SUFFIX) >= sizeof(buf)) { fprintf(stderr, "%s: filename too long\n", prog); diff --git a/contrib/zlib/trees.c b/contrib/zlib/trees.c index 1fd7759..50cf4b4 100644 --- a/contrib/zlib/trees.c +++ b/contrib/zlib/trees.c @@ -1,5 +1,5 @@ /* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2012 Jean-loup Gailly + * Copyright (C) 1995-2017 Jean-loup Gailly * detect_data_type() function provided freely by Cosmin Truta, 2006 * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -36,7 +36,7 @@ #include "deflate.h" -#ifdef DEBUG +#ifdef ZLIB_DEBUG # include #endif @@ -122,13 +122,13 @@ struct static_tree_desc_s { int max_length; /* max bit length for the codes */ }; -local static_tree_desc static_l_desc = +local const static_tree_desc static_l_desc = {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; -local static_tree_desc static_d_desc = +local const static_tree_desc static_d_desc = {static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; -local static_tree_desc static_bl_desc = +local const static_tree_desc static_bl_desc = {(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; /* =========================================================================== @@ -152,18 +152,16 @@ local int detect_data_type OF((deflate_state *s)); local unsigned bi_reverse OF((unsigned value, int length)); local void bi_windup OF((deflate_state *s)); local void bi_flush OF((deflate_state *s)); -local void copy_block OF((deflate_state *s, charf *buf, unsigned len, - int header)); #ifdef GEN_TREES_H local void gen_trees_header OF((void)); #endif -#ifndef DEBUG +#ifndef ZLIB_DEBUG # define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) /* Send a code of the given tree. c and tree must not have side effects */ -#else /* DEBUG */ +#else /* !ZLIB_DEBUG */ # define send_code(s, c, tree) \ { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ send_bits(s, tree[c].Code, tree[c].Len); } @@ -182,7 +180,7 @@ local void gen_trees_header OF((void)); * Send a value on a given number of bits. * IN assertion: length <= 16 and value fits in length bits. */ -#ifdef DEBUG +#ifdef ZLIB_DEBUG local void send_bits OF((deflate_state *s, int value, int length)); local void send_bits(s, value, length) @@ -208,12 +206,12 @@ local void send_bits(s, value, length) s->bi_valid += length; } } -#else /* !DEBUG */ +#else /* !ZLIB_DEBUG */ #define send_bits(s, value, length) \ { int len = length;\ if (s->bi_valid > (int)Buf_size - len) {\ - int val = value;\ + int val = (int)value;\ s->bi_buf |= (ush)val << s->bi_valid;\ put_short(s, s->bi_buf);\ s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ @@ -223,7 +221,7 @@ local void send_bits(s, value, length) s->bi_valid += len;\ }\ } -#endif /* DEBUG */ +#endif /* ZLIB_DEBUG */ /* the arguments must not have side effects */ @@ -317,7 +315,7 @@ local void tr_static_init() * Genererate the file trees.h describing the static trees. */ #ifdef GEN_TREES_H -# ifndef DEBUG +# ifndef ZLIB_DEBUG # include # endif @@ -394,7 +392,7 @@ void ZLIB_INTERNAL _tr_init(s) s->bi_buf = 0; s->bi_valid = 0; -#ifdef DEBUG +#ifdef ZLIB_DEBUG s->compressed_len = 0L; s->bits_sent = 0L; #endif @@ -522,12 +520,12 @@ local void gen_bitlen(s, desc) xbits = 0; if (n >= base) xbits = extra[n-base]; f = tree[n].Freq; - s->opt_len += (ulg)f * (bits + xbits); - if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); + s->opt_len += (ulg)f * (unsigned)(bits + xbits); + if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits); } if (overflow == 0) return; - Trace((stderr,"\nbit length overflow\n")); + Tracev((stderr,"\nbit length overflow\n")); /* This happens for example on obj2 and pic of the Calgary corpus */ /* Find the first bit length which could increase: */ @@ -554,9 +552,8 @@ local void gen_bitlen(s, desc) m = s->heap[--h]; if (m > max_code) continue; if ((unsigned) tree[m].Len != (unsigned) bits) { - Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); - s->opt_len += ((long)bits - (long)tree[m].Len) - *(long)tree[m].Freq; + Tracev((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); + s->opt_len += ((ulg)bits - tree[m].Len) * tree[m].Freq; tree[m].Len = (ush)bits; } n--; @@ -578,7 +575,7 @@ local void gen_codes (tree, max_code, bl_count) ushf *bl_count; /* number of codes at each bit length */ { ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - ush code = 0; /* running code value */ + unsigned code = 0; /* running code value */ int bits; /* bit index */ int n; /* code index */ @@ -586,7 +583,8 @@ local void gen_codes (tree, max_code, bl_count) * without bit reversal. */ for (bits = 1; bits <= MAX_BITS; bits++) { - next_code[bits] = code = (code + bl_count[bits-1]) << 1; + code = (code + bl_count[bits-1]) << 1; + next_code[bits] = (ush)code; } /* Check that the bit counts in bl_count are consistent. The last code * must be all ones. @@ -599,7 +597,7 @@ local void gen_codes (tree, max_code, bl_count) int len = tree[n].Len; if (len == 0) continue; /* Now reverse the bits */ - tree[n].Code = bi_reverse(next_code[len]++, len); + tree[n].Code = (ush)bi_reverse(next_code[len]++, len); Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1)); @@ -821,7 +819,7 @@ local int build_bl_tree(s) if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; } /* Update opt_len to include the bit length tree and counts */ - s->opt_len += 3*(max_blindex+1) + 5+5+4; + s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4; Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", s->opt_len, s->static_len)); @@ -869,11 +867,17 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) int last; /* one if this is the last block for a file */ { send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */ -#ifdef DEBUG + bi_windup(s); /* align on byte boundary */ + put_short(s, (ush)stored_len); + put_short(s, (ush)~stored_len); + zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len); + s->pending += stored_len; +#ifdef ZLIB_DEBUG s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; s->compressed_len += (stored_len + 4) << 3; + s->bits_sent += 2*16; + s->bits_sent += stored_len<<3; #endif - copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ } /* =========================================================================== @@ -894,7 +898,7 @@ void ZLIB_INTERNAL _tr_align(s) { send_bits(s, STATIC_TREES<<1, 3); send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG +#ifdef ZLIB_DEBUG s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ #endif bi_flush(s); @@ -902,7 +906,7 @@ void ZLIB_INTERNAL _tr_align(s) /* =========================================================================== * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and output the encoded block to the zip file. + * trees or store, and write out the encoded block. */ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) deflate_state *s; @@ -974,7 +978,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) send_bits(s, (STATIC_TREES<<1)+last, 3); compress_block(s, (const ct_data *)static_ltree, (const ct_data *)static_dtree); -#ifdef DEBUG +#ifdef ZLIB_DEBUG s->compressed_len += 3 + s->static_len; #endif } else { @@ -983,7 +987,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) max_blindex+1); compress_block(s, (const ct_data *)s->dyn_ltree, (const ct_data *)s->dyn_dtree); -#ifdef DEBUG +#ifdef ZLIB_DEBUG s->compressed_len += 3 + s->opt_len; #endif } @@ -995,7 +999,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) if (last) { bi_windup(s); -#ifdef DEBUG +#ifdef ZLIB_DEBUG s->compressed_len += 7; /* align on byte boundary */ #endif } @@ -1090,7 +1094,7 @@ local void compress_block(s, ltree, dtree) send_code(s, code, dtree); /* send the distance code */ extra = extra_dbits[code]; if (extra != 0) { - dist -= base_dist[code]; + dist -= (unsigned)base_dist[code]; send_bits(s, dist, extra); /* send the extra distance bits */ } } /* literal or match pair ? */ @@ -1193,34 +1197,7 @@ local void bi_windup(s) } s->bi_buf = 0; s->bi_valid = 0; -#ifdef DEBUG +#ifdef ZLIB_DEBUG s->bits_sent = (s->bits_sent+7) & ~7; #endif } - -/* =========================================================================== - * Copy a stored block, storing first the length and its - * one's complement if requested. - */ -local void copy_block(s, buf, len, header) - deflate_state *s; - charf *buf; /* the input data */ - unsigned len; /* its length */ - int header; /* true if block header must be written */ -{ - bi_windup(s); /* align on byte boundary */ - - if (header) { - put_short(s, (ush)len); - put_short(s, (ush)~len); -#ifdef DEBUG - s->bits_sent += 2*16; -#endif - } -#ifdef DEBUG - s->bits_sent += (ulg)len<<3; -#endif - while (len--) { - put_byte(s, *buf++); - } -} diff --git a/contrib/zlib/uncompr.c b/contrib/zlib/uncompr.c index 242e949..f03a1a8 100644 --- a/contrib/zlib/uncompr.c +++ b/contrib/zlib/uncompr.c @@ -1,5 +1,5 @@ /* uncompr.c -- decompress a memory buffer - * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. + * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,51 +9,85 @@ #include "zlib.h" /* =========================================================================== - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted. + Decompresses the source buffer into the destination buffer. *sourceLen is + the byte length of the source buffer. Upon entry, *destLen is the total size + of the destination buffer, which must be large enough to hold the entire + uncompressed data. (The size of the uncompressed data must have been saved + previously by the compressor and transmitted to the decompressor by some + mechanism outside the scope of this compression library.) Upon exit, + *destLen is the size of the decompressed data and *sourceLen is the number + of source bytes consumed. Upon return, source + *sourceLen points to the + first unused input byte. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, or + Z_DATA_ERROR if the input data was corrupted, including if the input data is + an incomplete zlib stream. */ -int ZEXPORT uncompress (dest, destLen, source, sourceLen) +int ZEXPORT uncompress2 (dest, destLen, source, sourceLen) Bytef *dest; uLongf *destLen; const Bytef *source; - uLong sourceLen; + uLong *sourceLen; { z_stream stream; int err; + const uInt max = (uInt)-1; + uLong len, left; + Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */ - stream.next_in = (z_const Bytef *)source; - stream.avail_in = (uInt)sourceLen; - /* Check for source > 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; - - stream.next_out = dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; + len = *sourceLen; + if (*destLen) { + left = *destLen; + *destLen = 0; + } + else { + left = 1; + dest = buf; + } + stream.next_in = (z_const Bytef *)source; + stream.avail_in = 0; stream.zalloc = (alloc_func)0; stream.zfree = (free_func)0; + stream.opaque = (voidpf)0; err = inflateInit(&stream); if (err != Z_OK) return err; - err = inflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - inflateEnd(&stream); - if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) - return Z_DATA_ERROR; - return err; - } - *destLen = stream.total_out; + stream.next_out = dest; + stream.avail_out = 0; - err = inflateEnd(&stream); - return err; + do { + if (stream.avail_out == 0) { + stream.avail_out = left > (uLong)max ? max : (uInt)left; + left -= stream.avail_out; + } + if (stream.avail_in == 0) { + stream.avail_in = len > (uLong)max ? max : (uInt)len; + len -= stream.avail_in; + } + err = inflate(&stream, Z_NO_FLUSH); + } while (err == Z_OK); + + *sourceLen -= len + stream.avail_in; + if (dest != buf) + *destLen = stream.total_out; + else if (stream.total_out && err == Z_BUF_ERROR) + left = 1; + + inflateEnd(&stream); + return err == Z_STREAM_END ? Z_OK : + err == Z_NEED_DICT ? Z_DATA_ERROR : + err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR : + err; +} + +int ZEXPORT uncompress (dest, destLen, source, sourceLen) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; +{ + return uncompress2(dest, destLen, source, &sourceLen); } diff --git a/contrib/zlib/zconf.h b/contrib/zlib/zconf.h index 13a2e1c..0654395 100644 --- a/contrib/zlib/zconf.h +++ b/contrib/zlib/zconf.h @@ -1,5 +1,5 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2013 Jean-loup Gailly. + * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -17,7 +17,7 @@ #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ # define Z_PREFIX_SET -/* all linked symbols */ +/* all linked symbols and init macros */ # define _dist_code z__dist_code # define _length_code z__length_code # define _tr_align z__tr_align @@ -29,6 +29,7 @@ # define adler32 z_adler32 # define adler32_combine z_adler32_combine # define adler32_combine64 z_adler32_combine64 +# define adler32_z z_adler32_z # ifndef Z_SOLO # define compress z_compress # define compress2 z_compress2 @@ -37,10 +38,14 @@ # define crc32 z_crc32 # define crc32_combine z_crc32_combine # define crc32_combine64 z_crc32_combine64 +# define crc32_z z_crc32_z # define deflate z_deflate # define deflateBound z_deflateBound # define deflateCopy z_deflateCopy # define deflateEnd z_deflateEnd +# define deflateGetDictionary z_deflateGetDictionary +# define deflateInit z_deflateInit +# define deflateInit2 z_deflateInit2 # define deflateInit2_ z_deflateInit2_ # define deflateInit_ z_deflateInit_ # define deflateParams z_deflateParams @@ -67,6 +72,8 @@ # define gzeof z_gzeof # define gzerror z_gzerror # define gzflush z_gzflush +# define gzfread z_gzfread +# define gzfwrite z_gzfwrite # define gzgetc z_gzgetc # define gzgetc_ z_gzgetc_ # define gzgets z_gzgets @@ -78,7 +85,6 @@ # define gzopen_w z_gzopen_w # endif # define gzprintf z_gzprintf -# define gzvprintf z_gzvprintf # define gzputc z_gzputc # define gzputs z_gzputs # define gzread z_gzread @@ -89,32 +95,39 @@ # define gztell z_gztell # define gztell64 z_gztell64 # define gzungetc z_gzungetc +# define gzvprintf z_gzvprintf # define gzwrite z_gzwrite # endif # define inflate z_inflate # define inflateBack z_inflateBack # define inflateBackEnd z_inflateBackEnd +# define inflateBackInit z_inflateBackInit # define inflateBackInit_ z_inflateBackInit_ +# define inflateCodesUsed z_inflateCodesUsed # define inflateCopy z_inflateCopy # define inflateEnd z_inflateEnd +# define inflateGetDictionary z_inflateGetDictionary # define inflateGetHeader z_inflateGetHeader +# define inflateInit z_inflateInit +# define inflateInit2 z_inflateInit2 # define inflateInit2_ z_inflateInit2_ # define inflateInit_ z_inflateInit_ # define inflateMark z_inflateMark # define inflatePrime z_inflatePrime # define inflateReset z_inflateReset # define inflateReset2 z_inflateReset2 +# define inflateResetKeep z_inflateResetKeep # define inflateSetDictionary z_inflateSetDictionary -# define inflateGetDictionary z_inflateGetDictionary # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateUndermine z_inflateUndermine -# define inflateResetKeep z_inflateResetKeep +# define inflateValidate z_inflateValidate # define inflate_copyright z_inflate_copyright # define inflate_fast z_inflate_fast # define inflate_table z_inflate_table # ifndef Z_SOLO # define uncompress z_uncompress +# define uncompress2 z_uncompress2 # endif # define zError z_zError # ifndef Z_SOLO @@ -224,9 +237,19 @@ # define z_const #endif -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) -# define NO_DUMMY_DECL +#ifdef Z_SOLO + typedef unsigned long z_size_t; +#else +# define z_longlong long long +# if defined(NO_SIZE_T) + typedef unsigned NO_SIZE_T z_size_t; +# elif defined(STDC) +# include + typedef size_t z_size_t; +# else + typedef unsigned long z_size_t; +# endif +# undef z_longlong #endif /* Maximum value for memLevel in deflateInit2 */ @@ -256,7 +279,7 @@ Of course this will generally degrade compression (there's no free lunch). The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes + that is, 32K for windowBits=15 (default value) plus about 7 kilobytes for small objects. */ diff --git a/contrib/zlib/zconf.h.in b/contrib/zlib/zconf.h.in index 9987a77..5e1d68a 100644 --- a/contrib/zlib/zconf.h.in +++ b/contrib/zlib/zconf.h.in @@ -1,5 +1,5 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2013 Jean-loup Gailly. + * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -17,7 +17,7 @@ #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ # define Z_PREFIX_SET -/* all linked symbols */ +/* all linked symbols and init macros */ # define _dist_code z__dist_code # define _length_code z__length_code # define _tr_align z__tr_align @@ -29,6 +29,7 @@ # define adler32 z_adler32 # define adler32_combine z_adler32_combine # define adler32_combine64 z_adler32_combine64 +# define adler32_z z_adler32_z # ifndef Z_SOLO # define compress z_compress # define compress2 z_compress2 @@ -37,10 +38,14 @@ # define crc32 z_crc32 # define crc32_combine z_crc32_combine # define crc32_combine64 z_crc32_combine64 +# define crc32_z z_crc32_z # define deflate z_deflate # define deflateBound z_deflateBound # define deflateCopy z_deflateCopy # define deflateEnd z_deflateEnd +# define deflateGetDictionary z_deflateGetDictionary +# define deflateInit z_deflateInit +# define deflateInit2 z_deflateInit2 # define deflateInit2_ z_deflateInit2_ # define deflateInit_ z_deflateInit_ # define deflateParams z_deflateParams @@ -67,6 +72,8 @@ # define gzeof z_gzeof # define gzerror z_gzerror # define gzflush z_gzflush +# define gzfread z_gzfread +# define gzfwrite z_gzfwrite # define gzgetc z_gzgetc # define gzgetc_ z_gzgetc_ # define gzgets z_gzgets @@ -78,7 +85,6 @@ # define gzopen_w z_gzopen_w # endif # define gzprintf z_gzprintf -# define gzvprintf z_gzvprintf # define gzputc z_gzputc # define gzputs z_gzputs # define gzread z_gzread @@ -89,32 +95,39 @@ # define gztell z_gztell # define gztell64 z_gztell64 # define gzungetc z_gzungetc +# define gzvprintf z_gzvprintf # define gzwrite z_gzwrite # endif # define inflate z_inflate # define inflateBack z_inflateBack # define inflateBackEnd z_inflateBackEnd +# define inflateBackInit z_inflateBackInit # define inflateBackInit_ z_inflateBackInit_ +# define inflateCodesUsed z_inflateCodesUsed # define inflateCopy z_inflateCopy # define inflateEnd z_inflateEnd +# define inflateGetDictionary z_inflateGetDictionary # define inflateGetHeader z_inflateGetHeader +# define inflateInit z_inflateInit +# define inflateInit2 z_inflateInit2 # define inflateInit2_ z_inflateInit2_ # define inflateInit_ z_inflateInit_ # define inflateMark z_inflateMark # define inflatePrime z_inflatePrime # define inflateReset z_inflateReset # define inflateReset2 z_inflateReset2 +# define inflateResetKeep z_inflateResetKeep # define inflateSetDictionary z_inflateSetDictionary -# define inflateGetDictionary z_inflateGetDictionary # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateUndermine z_inflateUndermine -# define inflateResetKeep z_inflateResetKeep +# define inflateValidate z_inflateValidate # define inflate_copyright z_inflate_copyright # define inflate_fast z_inflate_fast # define inflate_table z_inflate_table # ifndef Z_SOLO # define uncompress z_uncompress +# define uncompress2 z_uncompress2 # endif # define zError z_zError # ifndef Z_SOLO @@ -224,9 +237,19 @@ # define z_const #endif -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) -# define NO_DUMMY_DECL +#ifdef Z_SOLO + typedef unsigned long z_size_t; +#else +# define z_longlong long long +# if defined(NO_SIZE_T) + typedef unsigned NO_SIZE_T z_size_t; +# elif defined(STDC) +# include + typedef size_t z_size_t; +# else + typedef unsigned long z_size_t; +# endif +# undef z_longlong #endif /* Maximum value for memLevel in deflateInit2 */ @@ -256,7 +279,7 @@ Of course this will generally degrade compression (there's no free lunch). The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes + that is, 32K for windowBits=15 (default value) plus about 7 kilobytes for small objects. */ diff --git a/contrib/zlib/zlib.3 b/contrib/zlib/zlib.3 index 0160e62..bda4eb0 100644 --- a/contrib/zlib/zlib.3 +++ b/contrib/zlib/zlib.3 @@ -1,4 +1,4 @@ -.TH ZLIB 3 "28 Apr 2013" +.TH ZLIB 3 "15 Jan 2017" .SH NAME zlib \- compression/decompression library .SH SYNOPSIS @@ -48,32 +48,10 @@ Changes to this version are documented in the file that accompanies the source. .LP .I zlib -is available in Java using the java.util.zip package: -.IP -http://java.sun.com/developer/technicalArticles/Programming/compression/ -.LP -A Perl interface to -.IR zlib , -written by Paul Marquess (pmqs@cpan.org), -is available at CPAN (Comprehensive Perl Archive Network) sites, -including: -.IP -http://search.cpan.org/~pmqs/IO-Compress-Zlib/ -.LP -A Python interface to -.IR zlib , -written by A.M. Kuchling (amk@magnet.com), -is available in Python 1.5 and later versions: -.IP -http://docs.python.org/library/zlib.html -.LP -.I zlib -is built into -.IR tcl: -.IP -http://wiki.tcl.tk/4610 +is built in to many languages and operating systems, including but not limited to +Java, Python, .NET, PHP, Perl, Ruby, Swift, and Go. .LP -An experimental package to read and write files in .zip format, +An experimental package to read and write files in the .zip format, written on top of .I zlib by Gilles Vollant (info@winimage.com), @@ -92,7 +70,9 @@ web site can be found at: .IP http://zlib.net/ .LP -The data format used by the zlib library is described by RFC +The data format used by the +.I zlib +library is described by RFC (Request for Comments) 1950 to 1952 in the files: .IP http://tools.ietf.org/html/rfc1950 (for the zlib header and trailer format) @@ -124,17 +104,35 @@ http://zlib.net/zlib_faq.html before asking for help. Send questions and/or comments to zlib@gzip.org, or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). -.SH AUTHORS -Version 1.2.8 -Copyright (C) 1995-2013 Jean-loup Gailly (jloup@gzip.org) -and Mark Adler (madler@alumni.caltech.edu). -.LP -This software is provided "as-is," -without any express or implied warranty. -In no event will the authors be held liable for any damages +.SH AUTHORS AND LICENSE +Version 1.2.11 +.LP +Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler +.LP +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages arising from the use of this software. -See the distribution directory with respect to requirements -governing redistribution. +.LP +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: +.LP +.nr step 1 1 +.IP \n[step]. 3 +The origin of this software must not be misrepresented; you must not +claim that you wrote the original software. If you use this software +in a product, an acknowledgment in the product documentation would be +appreciated but is not required. +.IP \n+[step]. +Altered source versions must be plainly marked as such, and must not be +misrepresented as being the original software. +.IP \n+[step]. +This notice may not be removed or altered from any source distribution. +.LP +Jean-loup Gailly Mark Adler +.br +jloup@gzip.org madler@alumni.caltech.edu +.LP The deflate format used by .I zlib was defined by Phil Katz. diff --git a/contrib/zlib/zlib.h b/contrib/zlib/zlib.h index 3e0c767..f09cdaf 100644 --- a/contrib/zlib/zlib.h +++ b/contrib/zlib/zlib.h @@ -1,7 +1,7 @@ /* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.8, April 28th, 2013 + version 1.2.11, January 15th, 2017 - Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler + Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -37,11 +37,11 @@ extern "C" { #endif -#define ZLIB_VERSION "1.2.8" -#define ZLIB_VERNUM 0x1280 +#define ZLIB_VERSION "1.2.11" +#define ZLIB_VERNUM 0x12b0 #define ZLIB_VER_MAJOR 1 #define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 8 +#define ZLIB_VER_REVISION 11 #define ZLIB_VER_SUBREVISION 0 /* @@ -65,7 +65,8 @@ extern "C" { with "gz". The gzip format is different from the zlib format. gzip is a gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - This library can optionally read and write gzip streams in memory as well. + This library can optionally read and write gzip and raw deflate streams in + memory as well. The zlib format was designed to be compact and fast for use in memory and on communications channels. The gzip format was designed for single- @@ -74,7 +75,7 @@ extern "C" { The library does not install any signal handler. The decoder checks the consistency of the compressed data, so the library should never crash - even in case of corrupted input. + even in the case of corrupted input. */ typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); @@ -87,7 +88,7 @@ typedef struct z_stream_s { uInt avail_in; /* number of bytes available at next_in */ uLong total_in; /* total number of input bytes read so far */ - Bytef *next_out; /* next output byte should be put there */ + Bytef *next_out; /* next output byte will go here */ uInt avail_out; /* remaining free space at next_out */ uLong total_out; /* total number of bytes output so far */ @@ -98,8 +99,9 @@ typedef struct z_stream_s { free_func zfree; /* used to free the internal state */ voidpf opaque; /* private data object passed to zalloc and zfree */ - int data_type; /* best guess about the data type: binary or text */ - uLong adler; /* adler32 value of the uncompressed data */ + int data_type; /* best guess about the data type: binary or text + for deflate, or the decoding state for inflate */ + uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */ uLong reserved; /* reserved for future use */ } z_stream; @@ -142,7 +144,9 @@ typedef gz_header FAR *gz_headerp; zalloc must return Z_NULL if there is not enough memory for the object. If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. + thread safe. In that case, zlib is thread-safe. When zalloc and zfree are + Z_NULL on entry to the initialization function, they are set to internal + routines that use the standard library functions malloc() and free(). On 16-bit systems, the functions zalloc and zfree must be able to allocate exactly 65536 bytes, but will not be required to allocate more than this if @@ -155,7 +159,7 @@ typedef gz_header FAR *gz_headerp; The fields total_in and total_out can be used for statistics or progress reports. After compression, total_in holds the total size of the - uncompressed data and may be saved for use in the decompressor (particularly + uncompressed data and may be saved for use by the decompressor (particularly if the decompressor wants to decompress everything in a single step). */ @@ -200,7 +204,7 @@ typedef gz_header FAR *gz_headerp; #define Z_TEXT 1 #define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ #define Z_UNKNOWN 2 -/* Possible values of the data_type field (though see inflate()) */ +/* Possible values of the data_type field for deflate() */ #define Z_DEFLATED 8 /* The deflate compression method (the only one supported in this version) */ @@ -258,11 +262,11 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); enough room in the output buffer), next_in and avail_in are updated and processing will resume at this point for the next call of deflate(). - - Provide more output starting at next_out and update next_out and avail_out + - Generate more output starting at next_out and update next_out and avail_out accordingly. This action is forced if the parameter flush is non zero. Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). Some - output may be provided even if flush is not set. + should be set only when necessary. Some output may be provided even if + flush is zero. Before the call of deflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more @@ -271,7 +275,9 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); output when it wants, for example when the output buffer is full (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK and with zero avail_out, it must be called again after making room in the output - buffer because there might be more output pending. + buffer because there might be more output pending. See deflatePending(), + which can be used if desired to determine whether or not there is more ouput + in that case. Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to decide how much data to accumulate before producing output, in order to @@ -292,8 +298,8 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. This completes the current deflate block and follows it with an empty fixed codes block that is 10 bits long. This assures that enough bytes are output - in order for the decompressor to finish the block before the empty fixed code - block. + in order for the decompressor to finish the block before the empty fixed + codes block. If flush is set to Z_BLOCK, a deflate block is completed and emitted, as for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to @@ -319,34 +325,38 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); If the parameter flush is set to Z_FINISH, pending input is processed, pending output is flushed and deflate returns with Z_STREAM_END if there was - enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the stream - are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least the - value returned by deflateBound (see below). Then deflate is guaranteed to - return Z_STREAM_END. If not enough output space is provided, deflate will - not return Z_STREAM_END, and it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). + enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this + function must be called again with Z_FINISH and more output space (updated + avail_out) but no more input data, until it returns with Z_STREAM_END or an + error. After deflate has returned Z_STREAM_END, the only possible operations + on the stream are deflateReset or deflateEnd. + + Z_FINISH can be used in the first deflate call after deflateInit if all the + compression is to be done in a single step. In order to complete in one + call, avail_out must be at least the value returned by deflateBound (see + below). Then deflate is guaranteed to return Z_STREAM_END. If not enough + output space is provided, deflate will not return Z_STREAM_END, and it must + be called again as described above. + + deflate() sets strm->adler to the Adler-32 checksum of all input read + so far (that is, total_in bytes). If a gzip stream is being generated, then + strm->adler will be the CRC-32 checksum of the input read so far. (See + deflateInit2 below.) deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered - binary. This field is only for information purposes and does not affect the - compression algorithm in any manner. + the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is + considered binary. This field is only for information purposes and does not + affect the compression algorithm in any manner. deflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if all input has been consumed and all output has been produced (only when flush is set to Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not - fatal, and deflate() can be called again with more input and more output - space to continue compressing. + if next_in or next_out was Z_NULL or the state was inadvertently written over + by the application), or Z_BUF_ERROR if no progress is possible (for example + avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and + deflate() can be called again with more input and more output space to + continue compressing. */ @@ -369,23 +379,21 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); Initializes the internal stream state for decompression. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the - exact value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. + the caller. In the current version of inflate, the provided input is not + read or consumed. The allocation of a sliding window will be deferred to + the first call of inflate (if the decompression does not complete on the + first call). If zalloc and zfree are set to Z_NULL, inflateInit updates + them to use default allocation functions. inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the version assumed by the caller, or Z_STREAM_ERROR if the parameters are invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit() does not process any header information -- that is deferred - until inflate() is called. + there is no error message. inflateInit does not perform any decompression. + Actual decompression will be done by inflate(). So next_in, and avail_in, + next_out, and avail_out are unused and unchanged. The current + implementation of inflateInit() does not process any header information -- + that is deferred until inflate() is called. */ @@ -401,17 +409,20 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); - Decompress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing will - resume at this point for the next call of inflate(). + enough room in the output buffer), then next_in and avail_in are updated + accordingly, and processing will resume at this point for the next call of + inflate(). - - Provide more output starting at next_out and update next_out and avail_out + - Generate more output starting at next_out and update next_out and avail_out accordingly. inflate() provides as much output as possible, until there is no more input data or no more space in the output buffer (see below about the flush parameter). Before the call of inflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more - output, and updating the next_* and avail_* values accordingly. The + output, and updating the next_* and avail_* values accordingly. If the + caller of inflate() does not provide both available input and available + output space, it is possible that there will be no progress made. The application can consume the uncompressed output when it wants, for example when the output buffer is full (avail_out == 0), or after each call of inflate(). If inflate returns Z_OK and with zero avail_out, it must be @@ -428,7 +439,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); gets to the end of that block, or when it runs out of data. The Z_BLOCK option assists in appending to or combining deflate streams. - Also to assist in this, on return inflate() will set strm->data_type to the + To assist in this, on return inflate() always sets strm->data_type to the number of unused bits in the last byte taken from strm->next_in, plus 64 if inflate() is currently decoding the last block in the deflate stream, plus 128 if inflate() returned immediately after decoding an end-of-block code or @@ -454,7 +465,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); this case all pending input is processed and all pending output is flushed; avail_out must be large enough to hold all of the uncompressed data for the operation to complete. (The size of the uncompressed data may have been - saved by the compressor for this purpose.) The use of Z_FINISH is not + saved by the compressor for this purpose.) The use of Z_FINISH is not required to perform an inflation in one step. However it may be used to inform inflate that a faster approach can be used for the single inflate() call. Z_FINISH also informs inflate to not maintain a sliding window if the @@ -476,32 +487,33 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); chosen by the compressor and returns Z_NEED_DICT; otherwise it sets strm->adler to the Adler-32 checksum of all output produced so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed adler32 + below. At the end of the stream, inflate() checks that its computed Adler-32 checksum is equal to that saved by the compressor and returns Z_STREAM_END only if the checksum is correct. inflate() can decompress and check either zlib-wrapped or gzip-wrapped deflate data. The header type is detected automatically, if requested when initializing with inflateInit2(). Any information contained in the gzip - header is not retained, so applications that need that information should - instead use raw inflate, see inflateInit2() below, or inflateBack() and - perform their own processing of the gzip header and trailer. When processing + header is not retained unless inflateGetHeader() is used. When processing gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output - producted so far. The CRC-32 is checked against the gzip trailer. + produced so far. The CRC-32 is checked against the gzip trailer, as is the + uncompressed length, modulo 2^32. inflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if the end of the compressed data has been reached and all uncompressed output has been produced, Z_NEED_DICT if a preset dictionary is needed at this point, Z_DATA_ERROR if the input data was corrupted (input stream not conforming to the zlib format or incorrect check - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example - next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory, - Z_BUF_ERROR if no progress is possible or if there was not enough room in the - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + value, in which case strm->msg points to a string with a more specific + error), Z_STREAM_ERROR if the stream structure was inconsistent (for example + next_in or next_out was Z_NULL, or the state was inadvertently written over + by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR + if no progress was possible or if there was not enough room in the output + buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and inflate() can be called again with more input and more output space to continue decompressing. If Z_DATA_ERROR is returned, the application may then call inflateSync() to look for a good compression block if a partial - recovery of the data is desired. + recovery of the data is to be attempted. */ @@ -511,9 +523,8 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); This function discards any unprocessed input and does not flush any pending output. - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). + inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state + was inconsistent. */ @@ -544,16 +555,29 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, compression at the expense of memory usage. The default value is 15 if deflateInit is used instead. + For the current implementation of deflate(), a windowBits value of 8 (a + window size of 256 bytes) is not supported. As a result, a request for 8 + will result in 9 (a 512-byte window). In that case, providing 8 to + inflateInit2() will result in an error when the zlib header with 9 is + checked against the initialization of inflate(). The remedy is to not use 8 + with deflateInit2() with this initialization, or at least in that case use 9 + with inflateInit2(). + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute an adler32 check value. + with no zlib header or trailer, and will not compute a check value. windowBits can also be greater than 15 for optional gzip encoding. Add 16 to windowBits to write a simple gzip header and trailer around the compressed data instead of a zlib wrapper. The gzip header will have no file name, no extra data, no comment, no modification time (set to zero), no - header crc, and the operating system will be set to 255 (unknown). If a - gzip stream is being written, strm->adler is a crc32 instead of an adler32. + header crc, and the operating system will be set to the appropriate value, + if the operating system was determined at compile time. If a gzip stream is + being written, strm->adler is a CRC-32 instead of an Adler-32. + + For raw deflate or gzip encoding, a request for a 256-byte window is + rejected as invalid, since only the zlib header provides a means of + transmitting the window size to the decompressor. The memLevel parameter specifies how much memory should be allocated for the internal compression state. memLevel=1 uses minimum memory but is @@ -614,12 +638,12 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, addition, the current implementation of deflate will use at most the window size minus 262 bytes of the provided dictionary. - Upon return of this function, strm->adler is set to the adler32 value + Upon return of this function, strm->adler is set to the Adler-32 value of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The adler32 value + which dictionary has been used by the compressor. (The Adler-32 value applies to the whole dictionary even if only a subset of the dictionary is actually used by the compressor.) If a raw deflate was requested, then the - adler32 value is not computed and strm->adler is not set. + Adler-32 value is not computed and strm->adler is not set. deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is @@ -628,6 +652,28 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, not perform any compression: this will be done by deflate(). */ +ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, + Bytef *dictionary, + uInt *dictLength)); +/* + Returns the sliding dictionary being maintained by deflate. dictLength is + set to the number of bytes in the dictionary, and that many bytes are copied + to dictionary. dictionary must have enough space, where 32768 bytes is + always enough. If deflateGetDictionary() is called with dictionary equal to + Z_NULL, then only the dictionary length is returned, and nothing is copied. + Similary, if dictLength is Z_NULL, then it is not set. + + deflateGetDictionary() may return a length less than the window size, even + when more than the window size in input has been provided. It may return up + to 258 bytes less in that case, due to how zlib's implementation of deflate + manages the sliding window and lookahead for matches, where matches can be + up to 258 bytes long. If the application needs the last window-size bytes of + input, then that would need to be saved by the application outside of zlib. + + deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the + stream state is inconsistent. +*/ + ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, z_streamp source)); /* @@ -648,10 +694,10 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); /* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. The - stream will keep the same compression level and any other attributes that - may have been set by deflateInit2. + This function is equivalent to deflateEnd followed by deflateInit, but + does not free and reallocate the internal compression state. The stream + will leave the compression level and any other attributes that may have been + set unchanged. deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL). @@ -662,20 +708,36 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, int strategy)); /* Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be + interpretation of level and strategy is as in deflateInit2(). This can be used to switch between compression and straight copy of the input data, or to switch to a different kind of input data requiring a different strategy. - If the compression level is changed, the input available so far is - compressed with the old level (and may be flushed); the new level will take - effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to be - compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if - strm->avail_out was zero. + If the compression approach (which is a function of the level) or the + strategy is changed, and if any input has been consumed in a previous + deflate() call, then the input available so far is compressed with the old + level and strategy using deflate(strm, Z_BLOCK). There are three approaches + for the compression levels 0, 1..3, and 4..9 respectively. The new level + and strategy will take effect at the next call of deflate(). + + If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does + not have enough output space to complete, then the parameter change will not + take effect. In this case, deflateParams() can be called again with the + same parameters and more output space to try again. + + In order to assure a change in the parameters on the first try, the + deflate stream should be flushed using deflate() with Z_BLOCK or other flush + request until strm.avail_out is not zero, before calling deflateParams(). + Then no more input data should be provided before the deflateParams() call. + If this is done, the old level and strategy will be applied to the data + compressed before deflateParams(), and the new level and strategy will be + applied to the the data compressed after deflateParams(). + + deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream + state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if + there was not enough output space to complete the compression of the + available input data before a change in the strategy or approach. Note that + in the case of a Z_BUF_ERROR, the parameters are not changed. A return + value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be + retried with more output space. */ ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, @@ -793,7 +855,7 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, is for use with other formats that use the deflate compressed data format such as zip. Those formats provide their own check values. If a custom format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an adler32 or a crc32 be applied to + recommended that a check value such as an Adler-32 or a CRC-32 be applied to the uncompressed data as is done in the zlib, gzip, and zip formats. For most applications, the zlib format should be used as is. Note that comments above on the use in deflateInit2() applies to the magnitude of windowBits. @@ -802,7 +864,10 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, 32 to windowBits to enable zlib and gzip decoding with automatic header detection, or add 16 to decode only the gzip format (the zlib format will return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a - crc32 instead of an adler32. + CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see + below), inflate() will not automatically decode concatenated gzip streams. + inflate() will return Z_STREAM_END at the end of the gzip stream. The state + would need to be reset to continue decoding a subsequent gzip stream. inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the @@ -823,7 +888,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of inflate, if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the adler32 value returned by that call of inflate. + can be determined from the Adler-32 value returned by that call of inflate. The compressor and decompressor must use exactly the same dictionary (see deflateSetDictionary). For raw inflate, this function can be called at any time to set the dictionary. If the provided dictionary is smaller than the @@ -834,7 +899,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect adler32 value). inflateSetDictionary does not + expected one (incorrect Adler-32 value). inflateSetDictionary does not perform any decompression: this will be done by subsequent calls of inflate(). */ @@ -892,7 +957,7 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); /* This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. The + but does not free and reallocate the internal decompression state. The stream will keep attributes that may have been set by inflateInit2. inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source @@ -904,7 +969,9 @@ ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, /* This function is the same as inflateReset, but it also permits changing the wrap and window size requests. The windowBits parameter is interpreted - the same as it is for inflateInit2. + the same as it is for inflateInit2. If the window size is changed, then the + memory allocated for the window is freed, and the window will be reallocated + by inflate() if needed. inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL), or if @@ -956,7 +1023,7 @@ ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); location in the input stream can be determined from avail_in and data_type as noted in the description for the Z_BLOCK flush parameter for inflate. - inflateMark returns the value noted above or -1 << 16 if the provided + inflateMark returns the value noted above, or -65536 if the provided source stream state was inconsistent. */ @@ -1048,9 +1115,9 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, This routine would normally be used in a utility that reads zip or gzip files and writes out uncompressed files. The utility would decode the header and process the trailer on its own, hence this routine expects only - the raw deflate stream to decompress. This is different from the normal - behavior of inflate(), which expects either a zlib or gzip header and - trailer around the deflate stream. + the raw deflate stream to decompress. This is different from the default + behavior of inflate(), which expects a zlib header and trailer around the + deflate stream. inflateBack() uses two subroutines supplied by the caller that are then called by inflateBack() for input and output. inflateBack() calls those @@ -1059,12 +1126,12 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, parameters and return types are defined above in the in_func and out_func typedefs. inflateBack() will call in(in_desc, &buf) which should return the number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero--buf is ignored in that - case--and inflateBack() will return a buffer error. inflateBack() will call - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() - should return zero on success, or non-zero on failure. If out() returns - non-zero, inflateBack() will return with an error. Neither in() nor out() - are permitted to change the contents of the window provided to + there is no input available, in() must return zero -- buf is ignored in that + case -- and inflateBack() will return a buffer error. inflateBack() will + call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. + out() should return zero on success, or non-zero on failure. If out() + returns non-zero, inflateBack() will return with an error. Neither in() nor + out() are permitted to change the contents of the window provided to inflateBackInit(), which is also the buffer that out() uses to write from. The length written by out() will be at most the window size. Any non-zero amount of input may be provided by in(). @@ -1092,7 +1159,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, using strm->next_in which will be Z_NULL only if in() returned an error. If strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning non-zero. (in() will always be called before out(), so strm->next_in is - assured to be defined if out() returns non-zero.) Note that inflateBack() + assured to be defined if out() returns non-zero.) Note that inflateBack() cannot return Z_OK. */ @@ -1114,7 +1181,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); 7.6: size of z_off_t Compiler, assembler, and debug options: - 8: DEBUG + 8: ZLIB_DEBUG 9: ASMV or ASMINF -- use ASM code 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention 11: 0 (reserved) @@ -1164,7 +1231,8 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. + compressed data. compress() is equivalent to compress2() with a level + parameter of Z_DEFAULT_COMPRESSION. compress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output @@ -1180,7 +1248,7 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. + compressed data. compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, @@ -1203,7 +1271,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, uncompressed data. (The size of the uncompressed data must have been saved previously by the compressor and transmitted to the decompressor by some mechanism outside the scope of this compression library.) Upon exit, destLen - is the actual size of the uncompressed buffer. + is the actual size of the uncompressed data. uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output @@ -1212,6 +1280,14 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, buffer with the uncompressed data up to that point. */ +ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong *sourceLen)); +/* + Same as uncompress, except that sourceLen is a pointer, where the + length of the source is *sourceLen. On return, *sourceLen is the number of + source bytes consumed. +*/ + /* gzip file access functions */ /* @@ -1290,10 +1366,9 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); default buffer size is 8192 bytes. This function must be called after gzopen() or gzdopen(), and before any other calls that read or write the file. The buffer memory allocation is always deferred to the first read or - write. Two buffers are allocated, either both of the specified size when - writing, or one of the specified size and the other twice that size when - reading. A larger buffer size of, for example, 64K or 128K bytes will - noticeably increase the speed of decompression (reading). + write. Three times that size in buffer space is allocated. A larger buffer + size of, for example, 64K or 128K bytes will noticeably increase the speed + of decompression (reading). The new buffer size also affects the maximum length for gzprintf(). @@ -1304,10 +1379,12 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); /* Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. + of deflateInit2 for the meaning of these parameters. Previously provided + data is flushed before the parameter change. - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. + gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not + opened for writing, Z_ERRNO if there is an error writing the flushed data, + or Z_MEM_ERROR if there is a memory allocation error. */ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); @@ -1335,7 +1412,35 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); case. gzread returns the number of uncompressed bytes actually read, less than - len for end of file, or -1 for error. + len for end of file, or -1 for error. If len is too large to fit in an int, + then nothing is read, -1 is returned, and the error state is set to + Z_STREAM_ERROR. +*/ + +ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, + gzFile file)); +/* + Read up to nitems items of size size from file to buf, otherwise operating + as gzread() does. This duplicates the interface of stdio's fread(), with + size_t request and return types. If the library defines size_t, then + z_size_t is identical to size_t. If not, then z_size_t is an unsigned + integer type that can contain a pointer. + + gzfread() returns the number of full items read of size size, or zero if + the end of the file was reached and a full item could not be read, or if + there was an error. gzerror() must be consulted if zero is returned in + order to determine if there was an error. If the multiplication of size and + nitems overflows, i.e. the product does not fit in a z_size_t, then nothing + is read, zero is returned, and the error state is set to Z_STREAM_ERROR. + + In the event that the end of file is reached and only a partial item is + available at the end, i.e. the remaining uncompressed data length is not a + multiple of size, then the final partial item is nevetheless read into buf + and the end-of-file flag is set. The length of the partial item read is not + provided, but could be inferred from the result of gztell(). This behavior + is the same as the behavior of fread() implementations in common libraries, + but it prevents the direct use of gzfread() to read a concurrently written + file, reseting and retrying on end-of-file, when size is not 1. */ ZEXTERN int ZEXPORT gzwrite OF((gzFile file, @@ -1346,19 +1451,33 @@ ZEXTERN int ZEXPORT gzwrite OF((gzFile file, error. */ +ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, + z_size_t nitems, gzFile file)); +/* + gzfwrite() writes nitems items of size size from buf to file, duplicating + the interface of stdio's fwrite(), with size_t request and return types. If + the library defines size_t, then z_size_t is identical to size_t. If not, + then z_size_t is an unsigned integer type that can contain a pointer. + + gzfwrite() returns the number of full items written of size size, or zero + if there was an error. If the multiplication of size and nitems overflows, + i.e. the product does not fit in a z_size_t, then nothing is written, zero + is returned, and the error state is set to Z_STREAM_ERROR. +*/ + ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); /* Converts, formats, and writes the arguments to the compressed file under control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written, or 0 in case of error. The number of - uncompressed bytes written is limited to 8191, or one less than the buffer - size given to gzbuffer(). The caller should assure that this limit is not - exceeded. If it is exceeded, then gzprintf() will return an error (0) with - nothing written. In this case, there may also be a buffer overflow with - unpredictable consequences, which is possible only if zlib was compiled with - the insecure functions sprintf() or vsprintf() because the secure snprintf() - or vsnprintf() functions were not available. This can be determined using - zlibCompileFlags(). + uncompressed bytes actually written, or a negative zlib error code in case + of error. The number of uncompressed bytes written is limited to 8191, or + one less than the buffer size given to gzbuffer(). The caller should assure + that this limit is not exceeded. If it is exceeded, then gzprintf() will + return an error (0) with nothing written. In this case, there may also be a + buffer overflow with unpredictable consequences, which is possible only if + zlib was compiled with the insecure functions sprintf() or vsprintf() + because the secure snprintf() or vsnprintf() functions were not available. + This can be determined using zlibCompileFlags(). */ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); @@ -1418,7 +1537,7 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); If the flush parameter is Z_FINISH, the remaining data is written and the gzip stream is completed in the output. If gzwrite() is called again, a new gzip stream will be started in the output. gzread() is able to read such - concatented gzip streams. + concatenated gzip streams. gzflush should be called only when strictly necessary because it will degrade compression if called too often. @@ -1572,7 +1691,7 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); return the updated checksum. If buf is Z_NULL, this function returns the required initial value for the checksum. - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed much faster. Usage example: @@ -1585,6 +1704,12 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); if (adler != original_adler) error(); */ +ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, + z_size_t len)); +/* + Same as adler32(), but with a size_t length. +*/ + /* ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, z_off_t len2)); @@ -1614,6 +1739,12 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); if (crc != original_crc) error(); */ +ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf, + z_size_t len)); +/* + Same as crc32(), but with a size_t length. +*/ + /* ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); @@ -1644,19 +1775,35 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, unsigned char FAR *window, const char *version, int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ - (int)sizeof(z_stream)) -#define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, (int)sizeof(z_stream)) +#ifdef Z_PREFIX_SET +# define z_deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) +# define z_inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) +# define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) +# define z_inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ + (int)sizeof(z_stream)) +# define z_inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, (int)sizeof(z_stream)) +#else +# define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) +# define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) +# define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) +# define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ + (int)sizeof(z_stream)) +# define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, (int)sizeof(z_stream)) +#endif #ifndef Z_SOLO @@ -1676,10 +1823,10 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ #ifdef Z_PREFIX_SET # undef z_gzgetc # define z_gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) #else # define gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) #endif /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or @@ -1737,19 +1884,16 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ #endif /* !Z_SOLO */ -/* hack for buggy compilers */ -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; -#endif - /* undocumented functions */ ZEXTERN const char * ZEXPORT zError OF((int)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); +ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); +ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp)); ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); -#if defined(_WIN32) && !defined(Z_SOLO) +#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO) ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, const char *mode)); #endif diff --git a/contrib/zlib/zlib.map b/contrib/zlib/zlib.map index 55c6647..40fa9db 100644 --- a/contrib/zlib/zlib.map +++ b/contrib/zlib/zlib.map @@ -1,83 +1,94 @@ -ZLIB_1.2.0 { - global: - compressBound; - deflateBound; - inflateBack; - inflateBackEnd; - inflateBackInit_; - inflateCopy; - local: - deflate_copyright; - inflate_copyright; - inflate_fast; - inflate_table; - zcalloc; - zcfree; - z_errmsg; - gz_error; - gz_intmax; - _*; -}; - -ZLIB_1.2.0.2 { - gzclearerr; - gzungetc; - zlibCompileFlags; -} ZLIB_1.2.0; - -ZLIB_1.2.0.8 { - deflatePrime; -} ZLIB_1.2.0.2; - -ZLIB_1.2.2 { - adler32_combine; - crc32_combine; - deflateSetHeader; - inflateGetHeader; -} ZLIB_1.2.0.8; - -ZLIB_1.2.2.3 { - deflateTune; - gzdirect; -} ZLIB_1.2.2; - -ZLIB_1.2.2.4 { - inflatePrime; -} ZLIB_1.2.2.3; - -ZLIB_1.2.3.3 { - adler32_combine64; - crc32_combine64; - gzopen64; - gzseek64; - gztell64; - inflateUndermine; -} ZLIB_1.2.2.4; - -ZLIB_1.2.3.4 { - inflateReset2; - inflateMark; -} ZLIB_1.2.3.3; - -ZLIB_1.2.3.5 { - gzbuffer; - gzoffset; - gzoffset64; - gzclose_r; - gzclose_w; -} ZLIB_1.2.3.4; - -ZLIB_1.2.5.1 { - deflatePending; -} ZLIB_1.2.3.5; - -ZLIB_1.2.5.2 { - deflateResetKeep; - gzgetc_; - inflateResetKeep; -} ZLIB_1.2.5.1; - -ZLIB_1.2.7.1 { - inflateGetDictionary; - gzvprintf; -} ZLIB_1.2.5.2; +ZLIB_1.2.0 { + global: + compressBound; + deflateBound; + inflateBack; + inflateBackEnd; + inflateBackInit_; + inflateCopy; + local: + deflate_copyright; + inflate_copyright; + inflate_fast; + inflate_table; + zcalloc; + zcfree; + z_errmsg; + gz_error; + gz_intmax; + _*; +}; + +ZLIB_1.2.0.2 { + gzclearerr; + gzungetc; + zlibCompileFlags; +} ZLIB_1.2.0; + +ZLIB_1.2.0.8 { + deflatePrime; +} ZLIB_1.2.0.2; + +ZLIB_1.2.2 { + adler32_combine; + crc32_combine; + deflateSetHeader; + inflateGetHeader; +} ZLIB_1.2.0.8; + +ZLIB_1.2.2.3 { + deflateTune; + gzdirect; +} ZLIB_1.2.2; + +ZLIB_1.2.2.4 { + inflatePrime; +} ZLIB_1.2.2.3; + +ZLIB_1.2.3.3 { + adler32_combine64; + crc32_combine64; + gzopen64; + gzseek64; + gztell64; + inflateUndermine; +} ZLIB_1.2.2.4; + +ZLIB_1.2.3.4 { + inflateReset2; + inflateMark; +} ZLIB_1.2.3.3; + +ZLIB_1.2.3.5 { + gzbuffer; + gzoffset; + gzoffset64; + gzclose_r; + gzclose_w; +} ZLIB_1.2.3.4; + +ZLIB_1.2.5.1 { + deflatePending; +} ZLIB_1.2.3.5; + +ZLIB_1.2.5.2 { + deflateResetKeep; + gzgetc_; + inflateResetKeep; +} ZLIB_1.2.5.1; + +ZLIB_1.2.7.1 { + inflateGetDictionary; + gzvprintf; +} ZLIB_1.2.5.2; + +ZLIB_1.2.9 { + inflateCodesUsed; + inflateValidate; + uncompress2; + gzfread; + gzfwrite; + deflateGetDictionary; + adler32_z; + crc32_z; +} ZLIB_1.2.7.1; diff --git a/contrib/zlib/zutil.c b/contrib/zlib/zutil.c index 23d2ebe..a76c6b0 100644 --- a/contrib/zlib/zutil.c +++ b/contrib/zlib/zutil.c @@ -1,5 +1,5 @@ /* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-2005, 2010, 2011, 2012 Jean-loup Gailly. + * Copyright (C) 1995-2017 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -10,21 +10,18 @@ # include "gzguts.h" #endif -#ifndef NO_DUMMY_DECL -struct internal_state {int dummy;}; /* for buggy compilers */ -#endif - z_const char * const z_errmsg[10] = { -"need dictionary", /* Z_NEED_DICT 2 */ -"stream end", /* Z_STREAM_END 1 */ -"", /* Z_OK 0 */ -"file error", /* Z_ERRNO (-1) */ -"stream error", /* Z_STREAM_ERROR (-2) */ -"data error", /* Z_DATA_ERROR (-3) */ -"insufficient memory", /* Z_MEM_ERROR (-4) */ -"buffer error", /* Z_BUF_ERROR (-5) */ -"incompatible version",/* Z_VERSION_ERROR (-6) */ -""}; + (z_const char *)"need dictionary", /* Z_NEED_DICT 2 */ + (z_const char *)"stream end", /* Z_STREAM_END 1 */ + (z_const char *)"", /* Z_OK 0 */ + (z_const char *)"file error", /* Z_ERRNO (-1) */ + (z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */ + (z_const char *)"data error", /* Z_DATA_ERROR (-3) */ + (z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */ + (z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */ + (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */ + (z_const char *)"" +}; const char * ZEXPORT zlibVersion() @@ -61,7 +58,7 @@ uLong ZEXPORT zlibCompileFlags() case 8: flags += 2 << 6; break; default: flags += 3 << 6; } -#ifdef DEBUG +#ifdef ZLIB_DEBUG flags += 1 << 8; #endif #if defined(ASMV) || defined(ASMINF) @@ -115,8 +112,8 @@ uLong ZEXPORT zlibCompileFlags() return flags; } -#ifdef DEBUG - +#ifdef ZLIB_DEBUG +#include # ifndef verbose # define verbose 0 # endif @@ -219,9 +216,11 @@ local ptr_table table[MAX_PTR]; voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) { - voidpf buf = opaque; /* just to make some compilers happy */ + voidpf buf; ulg bsize = (ulg)items*size; + (void)opaque; + /* If we allocate less than 65520 bytes, we assume that farmalloc * will return a usable pointer which doesn't have to be normalized. */ @@ -244,6 +243,9 @@ voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) { int n; + + (void)opaque; + if (*(ush*)&ptr != 0) { /* object < 64K */ farfree(ptr); return; @@ -259,7 +261,6 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) next_ptr--; return; } - ptr = opaque; /* just to make some compilers happy */ Assert(0, "zcfree: ptr not found"); } @@ -278,13 +279,13 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) { - if (opaque) opaque = 0; /* to make compiler happy */ + (void)opaque; return _halloc((long)items, size); } void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) { - if (opaque) opaque = 0; /* to make compiler happy */ + (void)opaque; _hfree(ptr); } @@ -306,7 +307,7 @@ voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) unsigned items; unsigned size; { - if (opaque) items += size - size; /* make compiler happy */ + (void)opaque; return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : (voidpf)calloc(items, size); } @@ -315,8 +316,8 @@ void ZLIB_INTERNAL zcfree (opaque, ptr) voidpf opaque; voidpf ptr; { + (void)opaque; free(ptr); - if (opaque) return; /* make compiler happy */ } #endif /* MY_ZCALLOC */ diff --git a/contrib/zlib/zutil.h b/contrib/zlib/zutil.h index 24ab06b..b079ea6 100644 --- a/contrib/zlib/zutil.h +++ b/contrib/zlib/zutil.h @@ -1,5 +1,5 @@ /* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2013 Jean-loup Gailly. + * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -36,7 +36,9 @@ #ifndef local # define local static #endif -/* compile with -Dlocal if your debugger can't find static symbols */ +/* since "static" is used to mean two completely different things in C, we + define "local" for the non-static meaning of "static", for readability + (compile with -Dlocal if your debugger can't find static symbols) */ typedef unsigned char uch; typedef uch FAR uchf; @@ -98,28 +100,38 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ #endif #ifdef AMIGA -# define OS_CODE 0x01 +# define OS_CODE 1 #endif #if defined(VAXC) || defined(VMS) -# define OS_CODE 0x02 +# define OS_CODE 2 # define F_OPEN(name, mode) \ fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") #endif +#ifdef __370__ +# if __TARGET_LIB__ < 0x20000000 +# define OS_CODE 4 +# elif __TARGET_LIB__ < 0x40000000 +# define OS_CODE 11 +# else +# define OS_CODE 8 +# endif +#endif + #if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 +# define OS_CODE 5 #endif #ifdef OS2 -# define OS_CODE 0x06 +# define OS_CODE 6 # if defined(M_I86) && !defined(Z_SOLO) # include # endif #endif #if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 0x07 +# define OS_CODE 7 # ifndef Z_SOLO # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os # include /* for fdopen */ @@ -131,18 +143,24 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # endif #endif -#ifdef TOPS20 -# define OS_CODE 0x0a +#ifdef __acorn +# define OS_CODE 13 #endif -#ifdef WIN32 -# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ -# define OS_CODE 0x0b -# endif +#if defined(WIN32) && !defined(__CYGWIN__) +# define OS_CODE 10 +#endif + +#ifdef _BEOS_ +# define OS_CODE 16 +#endif + +#ifdef __TOS_OS400__ +# define OS_CODE 18 #endif -#ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0f +#ifdef __APPLE__ +# define OS_CODE 19 #endif #if defined(_BEOS_) || defined(RISCOS) @@ -177,7 +195,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* common defaults */ #ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ +# define OS_CODE 3 /* assume Unix */ #endif #ifndef F_OPEN @@ -216,7 +234,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ #endif /* Diagnostic functions */ -#ifdef DEBUG +#ifdef ZLIB_DEBUG # include extern int ZLIB_INTERNAL z_verbose; extern void ZLIB_INTERNAL z_error OF((char *m)); diff --git a/lib/libz/Symbol.map b/lib/libz/Symbol.map index b117cdd..abff432 100644 --- a/lib/libz/Symbol.map +++ b/lib/libz/Symbol.map @@ -2,6 +2,17 @@ * $FreeBSD: head/lib/libz/Symbol.map 206709 2010-04-16 20:07:24Z delphij $ */ +ZLIB_1.2.9 { + inflateCodesUsed; + inflateValidate; + uncompress2; + gzfread; + gzfwrite; + deflateGetDictionary; + adler32_z; + crc32_z; +}; + ZLIB_1.2.7.1 { inflateGetDictionary; gzvprintf; diff --git a/lib/libz/Versions.def b/lib/libz/Versions.def index f8e6425..12df26e 100644 --- a/lib/libz/Versions.def +++ b/lib/libz/Versions.def @@ -9,6 +9,9 @@ ZLIB_1.2.7.0 { ZLIB_1.2.7.1 { } ZLIB_1.2.7.0; +ZLIB_1.2.9 { +} ZLIB_1.2.7.1; + FBSD_1.2 { } ZLIB_1.2.4.0; diff --git a/lib/libz/zlib.pc b/lib/libz/zlib.pc index 63a214f..b9ad734 100644 --- a/lib/libz/zlib.pc +++ b/lib/libz/zlib.pc @@ -7,7 +7,7 @@ includedir=${prefix}/include Name: zlib Description: zlib compression library -Version: 1.2.8 +Version: 1.2.10 Requires: Libs: -L${libdir} -L${sharedlibdir} -lz -- cgit v1.1 From 383f0463dc8fab606ae5715a5482c1bfbb51cb52 Mon Sep 17 00:00:00 2001 From: garga Date: Thu, 16 Feb 2017 09:19:29 +0000 Subject: MFC r313477: Cleanup on usr.sbin/arp/arp.c * 'blackhole' and 'reject' are mutually exclusive, replace printf() by errx() when both are selected. * 'trail' option is no longer supported since first import of arp from 4.4BSD. XXX message was added 13 years ago in r128192. I believe it's time to remove it. * Use warnx() to print some informative messages instead of printf() * Replace strncmp() by strcmp() when validating parameters and exit when invalid parameter is found Reviewed by: allanjude, vangyzen, cem Approved by: allanjude MFC after: 1 week Sponsored by: Rubicon Communications (Netgate) Differential Revision: https://reviews.freebsd.org/D9504 --- usr.sbin/arp/arp.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c index 2783b88..60079d4 100644 --- a/usr.sbin/arp/arp.c +++ b/usr.sbin/arp/arp.c @@ -319,7 +319,7 @@ set(int argc, char **argv) return (1); doing_proxy = flags = expire_time = 0; while (argc-- > 0) { - if (strncmp(argv[0], "temp", 4) == 0) { + if (strcmp(argv[0], "temp") == 0) { struct timespec tp; int max_age; size_t len = sizeof(max_age); @@ -329,10 +329,10 @@ set(int argc, char **argv) &max_age, &len, NULL, 0) != 0) err(1, "sysctlbyname"); expire_time = tp.tv_sec + max_age; - } else if (strncmp(argv[0], "pub", 3) == 0) { + } else if (strcmp(argv[0], "pub") == 0) { flags |= RTF_ANNOUNCE; doing_proxy = 1; - if (argc && strncmp(argv[1], "only", 3) == 0) { + if (argc && strcmp(argv[1], "only") == 0) { /* * Compatibility: in pre FreeBSD 8 times * the "only" keyword used to mean that @@ -341,29 +341,28 @@ set(int argc, char **argv) */ argc--; argv++; } - } else if (strncmp(argv[0], "blackhole", 9) == 0) { + } else if (strcmp(argv[0], "blackhole") == 0) { if (flags & RTF_REJECT) { - printf("Choose one of blackhole or reject, " + errx(1, "Choose one of blackhole or reject, " "not both."); } flags |= RTF_BLACKHOLE; - } else if (strncmp(argv[0], "reject", 6) == 0) { + } else if (strcmp(argv[0], "reject") == 0) { if (flags & RTF_BLACKHOLE) { - printf("Choose one of blackhole or reject, " + errx(1, "Choose one of blackhole or reject, " "not both."); } flags |= RTF_REJECT; - } else if (strncmp(argv[0], "trail", 5) == 0) { - /* XXX deprecated and undocumented feature */ - printf("%s: Sending trailers is no longer supported\n", - host); + } else { + warnx("Invalid parameter '%s'", argv[0]); + usage(); } argv++; } ea = (struct ether_addr *)LLADDR(&sdl_m); if (doing_proxy && !strcmp(eaddr, "auto")) { if (!get_ether_addr(dst->sin_addr.s_addr, ea)) { - printf("no interface found for %s\n", + warnx("no interface found for %s", inet_ntoa(dst->sin_addr)); return (1); } @@ -399,7 +398,7 @@ set(int argc, char **argv) if ((sdl->sdl_family != AF_LINK) || (rtm->rtm_flags & RTF_GATEWAY) || !valid_type(sdl->sdl_type)) { - printf("cannot intuit interface index and type for %s\n", host); + warnx("cannot intuit interface index and type for %s", host); return (1); } sdl_m.sdl_type = sdl->sdl_type; @@ -487,7 +486,7 @@ delete(char *host) * is a proxy-arp entry to remove. */ if (flags & RTF_ANNOUNCE) { - fprintf(stderr, "delete: cannot locate %s\n", host); + warnx("delete: cannot locate %s", host); return (1); } @@ -870,9 +869,8 @@ get_ether_addr(in_addr_t ipaddr, struct ether_addr *hwaddr) */ dla = (struct sockaddr_dl *) &ifr->ifr_addr; memcpy(hwaddr, LLADDR(dla), dla->sdl_alen); - printf("using interface %s for proxy with address ", - ifp->ifr_name); - printf("%s\n", ether_ntoa(hwaddr)); + printf("using interface %s for proxy with address %s\n", ifp->ifr_name, + ether_ntoa(hwaddr)); retval = dla->sdl_alen; done: close(sock); -- cgit v1.1 From eab442e4e8f405cb9a6f47680701fee725c84b07 Mon Sep 17 00:00:00 2001 From: grehan Date: Thu, 16 Feb 2017 17:08:43 +0000 Subject: MFC r311702 Use correct PCI device id for virtio-rng. This prevented the device from attaching with a Windows guest (most other guests use the device type for matching) PR: 212711 --- usr.sbin/bhyve/virtio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/virtio.h b/usr.sbin/bhyve/virtio.h index 0e96a1d..28eecc7 100644 --- a/usr.sbin/bhyve/virtio.h +++ b/usr.sbin/bhyve/virtio.h @@ -209,7 +209,7 @@ struct vring_used { #define VIRTIO_VENDOR 0x1AF4 #define VIRTIO_DEV_NET 0x1000 #define VIRTIO_DEV_BLOCK 0x1001 -#define VIRTIO_DEV_RANDOM 0x1002 +#define VIRTIO_DEV_RANDOM 0x1005 /* * PCI config space constants. -- cgit v1.1 From ee50f23a36e830ea4859dd36d55de33e5d66bddf Mon Sep 17 00:00:00 2001 From: kib Date: Fri, 17 Feb 2017 00:38:32 +0000 Subject: MFC r313715: Order alphabetically. --- sys/sys/syscallsubr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h index e038c98..046e048 100644 --- a/sys/sys/syscallsubr.h +++ b/sys/sys/syscallsubr.h @@ -158,8 +158,8 @@ int kern_mknod(struct thread *td, char *path, enum uio_seg pathseg, int kern_mknodat(struct thread *td, int fd, char *path, enum uio_seg pathseg, int mode, int dev); int kern_msgctl(struct thread *, int, int, struct msqid_ds *); -int kern_msgsnd(struct thread *, int, const void *, size_t, int, long); int kern_msgrcv(struct thread *, int, void *, size_t, long, int, long *); +int kern_msgsnd(struct thread *, int, const void *, size_t, int, long); int kern_nanosleep(struct thread *td, struct timespec *rqt, struct timespec *rmt); int kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap, -- cgit v1.1 From 4ae0bf7e940b0b987f7e915d58f5e8fd8c584bdb Mon Sep 17 00:00:00 2001 From: emaste Date: Fri, 17 Feb 2017 00:47:43 +0000 Subject: MFC r313562: kldxref: s/sections/segments/ in warning message The message refers to program header segments, not sections. PR: 216975 --- usr.sbin/kldxref/ef.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/kldxref/ef.c b/usr.sbin/kldxref/ef.c index 88fbc34..aa3fc2e 100644 --- a/usr.sbin/kldxref/ef.c +++ b/usr.sbin/kldxref/ef.c @@ -600,7 +600,7 @@ ef_open(const char *filename, struct elf_file *efile, int verbose) filename); break; } else if (nsegs > MAXSEGS) { - warnx("%s: too many sections", filename); + warnx("%s: too many segments", filename); break; } ef->ef_nsegs = nsegs; -- cgit v1.1 From d3b5abd4282ad6ec83d3d0e2697e4c32e1094664 Mon Sep 17 00:00:00 2001 From: emaste Date: Fri, 17 Feb 2017 00:49:01 +0000 Subject: MFC r313563: kldxref: bump MAXSEGS to 3 ld.bfd generates two PT_LOAD segments, but certain linkers or linker configurations generate three PT_LOAD segments (one additional for RELRO). PR: 216975 --- usr.sbin/kldxref/ef.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/kldxref/ef.c b/usr.sbin/kldxref/ef.c index aa3fc2e..d700b2a 100644 --- a/usr.sbin/kldxref/ef.c +++ b/usr.sbin/kldxref/ef.c @@ -47,7 +47,7 @@ #include "ef.h" -#define MAXSEGS 2 +#define MAXSEGS 3 struct ef_file { char* ef_name; struct elf_file *ef_efile; -- cgit v1.1 From 529339915e663a6d483fe6e50117f4d1766989a0 Mon Sep 17 00:00:00 2001 From: dim Date: Sat, 18 Feb 2017 14:44:14 +0000 Subject: Pull in r242377 from upstream libc++ trunk (by Marshall Clow): Make sure that __libcpp_compressed_pair_imp default-constructs its' members, rather than value-initializing them. Fixes PR#24137 This ensures std::make_shared<>'s default constructor properly initializes to zero. Direct commit to stable/9 and stable/10, since stable/11 and head already have a newer version of libc++, including this fix. Reported by: martin.beran@kernun.cz PR: 217200 --- contrib/libc++/include/memory | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contrib/libc++/include/memory b/contrib/libc++/include/memory index 662faa0..804b351 100644 --- a/contrib/libc++/include/memory +++ b/contrib/libc++/include/memory @@ -1950,11 +1950,11 @@ public: typedef const typename remove_reference<_T1>::type& _T1_const_reference; typedef const typename remove_reference<_T2>::type& _T2_const_reference; - _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} + _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_(), __second_() {} _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) - : __first_(_VSTD::forward<_T1_param>(__t1)) {} + : __first_(_VSTD::forward<_T1_param>(__t1)), __second_() {} _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) - : __second_(_VSTD::forward<_T2_param>(__t2)) {} + : __first_(), __second_(_VSTD::forward<_T2_param>(__t2)) {} _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) : __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} @@ -2043,9 +2043,9 @@ public: typedef const _T1& _T1_const_reference; typedef const typename remove_reference<_T2>::type& _T2_const_reference; - _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} + _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __second_() {} _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) - : _T1(_VSTD::forward<_T1_param>(__t1)) {} + : _T1(_VSTD::forward<_T1_param>(__t1)), __second_() {} _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) : __second_(_VSTD::forward<_T2_param>(__t2)) {} _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) @@ -2133,11 +2133,11 @@ public: typedef const typename remove_reference<_T1>::type& _T1_const_reference; typedef const _T2& _T2_const_reference; - _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {} + _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_() {} _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1) : __first_(_VSTD::forward<_T1_param>(__t1)) {} _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2) - : _T2(_VSTD::forward<_T2_param>(__t2)) {} + : _T2(_VSTD::forward<_T2_param>(__t2)), __first_() {} _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && is_nothrow_move_constructible<_T2>::value) -- cgit v1.1 From 3f0a7d0aa96ac1987ac4761899d2b410f61f0ac8 Mon Sep 17 00:00:00 2001 From: mm Date: Sat, 18 Feb 2017 21:59:19 +0000 Subject: MFC r313572,313782 Sync libarchive with vendor. MFC r313572: Vendor bugfixes: cpio reader sanity fix (OSS-Fuzz 504) WARC reader sanity fixes (OSS-Fuzz 511, 526, 532, 552) mtree reader time parsing fix (OSS-Fuzz 538) XAR reader memleak fix (OSS-Fuzz 551) MFC r313782: Vendor changes: Make SCHILY.acl.ace header more compact (NFSv4 ACLs) Vendor bugfixes: zip reader integer parsing fix (OSS-Fuzz 556) spelling fixes (issue #863) --- contrib/libarchive/libarchive/archive_acl.c | 173 ++++++++++----------- contrib/libarchive/libarchive/archive_entry.h | 5 + contrib/libarchive/libarchive/archive_entry_acl.3 | 9 +- .../libarchive/archive_read_disk_entry_from_file.c | 14 +- .../libarchive/archive_read_support_format_zip.c | 64 +++++--- .../libarchive/libarchive/archive_write_disk_acl.c | 14 +- .../libarchive/archive_write_set_format_pax.c | 3 +- .../libarchive/test/test_acl_pax_nfs4.tar.uu | 44 +++--- .../libarchive/test/test_acl_platform_posix1e.c | 2 +- contrib/libarchive/libarchive/test/test_acl_text.c | 13 +- 10 files changed, 188 insertions(+), 153 deletions(-) diff --git a/contrib/libarchive/libarchive/archive_acl.c b/contrib/libarchive/libarchive/archive_acl.c index 1e9ddbb..b8b6b63 100644 --- a/contrib/libarchive/libarchive/archive_acl.c +++ b/contrib/libarchive/libarchive/archive_acl.c @@ -83,6 +83,50 @@ static void append_entry(char **p, const char *prefix, int type, int tag, int flags, const char *name, int perm, int id); static void append_id(char **p, int id); +static const struct { + const int perm; + const char c; + const wchar_t wc; +} nfsv4_acl_perm_map[] = { + { ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, 'r', + L'r' }, + { ARCHIVE_ENTRY_ACL_WRITE_DATA | ARCHIVE_ENTRY_ACL_ADD_FILE, 'w', + L'w' }, + { ARCHIVE_ENTRY_ACL_EXECUTE, 'x', L'x' }, + { ARCHIVE_ENTRY_ACL_APPEND_DATA | ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, + 'p', L'p' }, + { ARCHIVE_ENTRY_ACL_DELETE, 'd', L'd' }, + { ARCHIVE_ENTRY_ACL_DELETE_CHILD, 'D', L'D' }, + { ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, 'a', L'a' }, + { ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, 'A', L'A' }, + { ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, 'R', L'R' }, + { ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, 'W', L'W' }, + { ARCHIVE_ENTRY_ACL_READ_ACL, 'c', L'c' }, + { ARCHIVE_ENTRY_ACL_WRITE_ACL, 'C', L'C' }, + { ARCHIVE_ENTRY_ACL_WRITE_OWNER, 'o', L'o' }, + { ARCHIVE_ENTRY_ACL_SYNCHRONIZE, 's', L's' } +}; + +static const int nfsv4_acl_perm_map_size = (int)(sizeof(nfsv4_acl_perm_map) / + sizeof(nfsv4_acl_perm_map[0])); + +static const struct { + const int perm; + const char c; + const wchar_t wc; +} nfsv4_acl_flag_map[] = { + { ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, 'f', L'f' }, + { ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, 'd', L'd' }, + { ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, 'i', L'i' }, + { ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, 'n', L'n' }, + { ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, 'S', L'S' }, + { ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, 'F', L'F' }, + { ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, 'I', L'I' } +}; + +static const int nfsv4_acl_flag_map_size = (int)(sizeof(nfsv4_acl_flag_map) / + sizeof(nfsv4_acl_flag_map[0])); + void archive_acl_clear(struct archive_acl *acl) { @@ -741,6 +785,8 @@ static void append_entry_w(wchar_t **wp, const wchar_t *prefix, int type, int tag, int flags, const wchar_t *wname, int perm, int id) { + int i; + if (prefix != NULL) { wcscpy(*wp, prefix); *wp += wcslen(*wp); @@ -810,46 +856,20 @@ append_entry_w(wchar_t **wp, const wchar_t *prefix, int type, *(*wp)++ = (perm & 0222) ? L'w' : L'-'; *(*wp)++ = (perm & 0111) ? L'x' : L'-'; } else { - /* NFS4 ACL perms */ - *(*wp)++ = (perm & (ARCHIVE_ENTRY_ACL_READ_DATA | - ARCHIVE_ENTRY_ACL_LIST_DIRECTORY)) ? L'r' : L'-'; - *(*wp)++ = (perm & (ARCHIVE_ENTRY_ACL_WRITE_DATA | - ARCHIVE_ENTRY_ACL_ADD_FILE)) ? L'w' : L'-'; - *(*wp)++ = (perm & ARCHIVE_ENTRY_ACL_EXECUTE) ? L'x' : L'-'; - *(*wp)++ = (perm & (ARCHIVE_ENTRY_ACL_APPEND_DATA | - ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY)) ? L'p' : L'-'; - *(*wp)++ = (perm & ARCHIVE_ENTRY_ACL_DELETE) ? L'd' : L'-'; - *(*wp)++ = (perm & - ARCHIVE_ENTRY_ACL_DELETE_CHILD) ? L'D' : L'-'; - *(*wp)++ = (perm & - ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES) ? L'a' : L'-'; - *(*wp)++ = (perm & - ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES) ? L'A' : L'-'; - *(*wp)++ = (perm & - ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS) ? L'R' : L'-'; - *(*wp)++ = (perm & - ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS) ? L'W' : L'-'; - *(*wp)++ = (perm & ARCHIVE_ENTRY_ACL_READ_ACL) ? L'c' : L'-'; - *(*wp)++ = (perm & ARCHIVE_ENTRY_ACL_WRITE_ACL) ? L'C' : L'-'; - *(*wp)++ = (perm & - ARCHIVE_ENTRY_ACL_WRITE_OWNER) ? L'o' : L'-'; - *(*wp)++ = (perm & - ARCHIVE_ENTRY_ACL_SYNCHRONIZE) ? L's' : L'-'; + /* NFSv4 ACL perms */ + for (i = 0; i < nfsv4_acl_perm_map_size; i++) { + if (perm & nfsv4_acl_perm_map[i].perm) + *(*wp)++ = nfsv4_acl_perm_map[i].wc; + else if ((flags & ARCHIVE_ENTRY_ACL_STYLE_COMPACT) == 0) + *(*wp)++ = L'-'; + } *(*wp)++ = L':'; - *(*wp)++ = (perm & - ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT) ? L'f' : L'-'; - *(*wp)++ = (perm & - ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT) ? L'd' : L'-'; - *(*wp)++ = (perm & - ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY) ? L'i' : L'-'; - *(*wp)++ = (perm & - ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT) ? L'n' : L'-'; - *(*wp)++ = (perm & - ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS) ? L'S' : L'-'; - *(*wp)++ = (perm & - ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS) ? L'F' : L'-'; - *(*wp)++ = (perm & - ARCHIVE_ENTRY_ACL_ENTRY_INHERITED) ? L'I' : L'-'; + for (i = 0; i < nfsv4_acl_flag_map_size; i++) { + if (perm & nfsv4_acl_flag_map[i].perm) + *(*wp)++ = nfsv4_acl_flag_map[i].wc; + else if ((flags & ARCHIVE_ENTRY_ACL_STYLE_COMPACT) == 0) + *(*wp)++ = L'-'; + } *(*wp)++ = L':'; switch (type) { case ARCHIVE_ENTRY_ACL_TYPE_ALLOW: @@ -998,6 +1018,8 @@ static void append_entry(char **p, const char *prefix, int type, int tag, int flags, const char *name, int perm, int id) { + int i; + if (prefix != NULL) { strcpy(*p, prefix); *p += strlen(*p); @@ -1067,47 +1089,20 @@ append_entry(char **p, const char *prefix, int type, *(*p)++ = (perm & 0222) ? 'w' : '-'; *(*p)++ = (perm & 0111) ? 'x' : '-'; } else { - /* NFS4 ACL perms */ - *(*p)++ = (perm & (ARCHIVE_ENTRY_ACL_READ_DATA | - ARCHIVE_ENTRY_ACL_LIST_DIRECTORY)) ? 'r' : '-'; - *(*p)++ = (perm & (ARCHIVE_ENTRY_ACL_WRITE_DATA | - ARCHIVE_ENTRY_ACL_ADD_FILE)) ? 'w' : '-'; - *(*p)++ = (perm & (ARCHIVE_ENTRY_ACL_EXECUTE)) ? 'x' : '-'; - *(*p)++ = (perm & (ARCHIVE_ENTRY_ACL_APPEND_DATA | - ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY)) ? 'p' : '-'; - *(*p)++ = (perm & ARCHIVE_ENTRY_ACL_DELETE) ? 'd' : '-'; - *(*p)++ = (perm & ARCHIVE_ENTRY_ACL_DELETE_CHILD) ? 'D' : '-'; - *(*p)++ = (perm & - ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES) ? 'a' : '-'; - *(*p)++ = (perm & - ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES) ? 'A' : '-'; - *(*p)++ = (perm & - ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS) ? 'R' : '-'; - *(*p)++ = (perm & - ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS) ? 'W' : '-'; - *(*p)++ = (perm & - ARCHIVE_ENTRY_ACL_READ_ACL) ? 'c' : '-'; - *(*p)++ = (perm & - ARCHIVE_ENTRY_ACL_WRITE_ACL) ? 'C' : '-'; - *(*p)++ = (perm & - ARCHIVE_ENTRY_ACL_WRITE_OWNER) ? 'o' : '-'; - *(*p)++ = (perm & - ARCHIVE_ENTRY_ACL_SYNCHRONIZE) ? 's' : '-'; + /* NFSv4 ACL perms */ + for (i = 0; i < nfsv4_acl_perm_map_size; i++) { + if (perm & nfsv4_acl_perm_map[i].perm) + *(*p)++ = nfsv4_acl_perm_map[i].c; + else if ((flags & ARCHIVE_ENTRY_ACL_STYLE_COMPACT) == 0) + *(*p)++ = '-'; + } *(*p)++ = ':'; - *(*p)++ = (perm & - ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT) ? 'f' : '-'; - *(*p)++ = (perm & - ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT) ? 'd' : '-'; - *(*p)++ = (perm & - ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY) ? 'i' : '-'; - *(*p)++ = (perm & - ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT) ? 'n' : '-'; - *(*p)++ = (perm & - ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS) ? 'S' : '-'; - *(*p)++ = (perm & - ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS) ? 'F' : '-'; - *(*p)++ = (perm & - ARCHIVE_ENTRY_ACL_ENTRY_INHERITED) ? 'I' : '-'; + for (i = 0; i < nfsv4_acl_flag_map_size; i++) { + if (perm & nfsv4_acl_flag_map[i].perm) + *(*p)++ = nfsv4_acl_flag_map[i].c; + else if ((flags & ARCHIVE_ENTRY_ACL_STYLE_COMPACT) == 0) + *(*p)++ = '-'; + } *(*p)++ = ':'; switch (type) { case ARCHIVE_ENTRY_ACL_TYPE_ALLOW: @@ -1467,11 +1462,8 @@ ismode_w(const wchar_t *start, const wchar_t *end, int *permset) static int is_nfs4_perms_w(const wchar_t *start, const wchar_t *end, int *permset) { - const wchar_t *p; + const wchar_t *p = start; - if (start >= end) - return (0); - p = start; while (p < end) { switch (*p++) { case L'r': @@ -1533,11 +1525,8 @@ is_nfs4_perms_w(const wchar_t *start, const wchar_t *end, int *permset) static int is_nfs4_flags_w(const wchar_t *start, const wchar_t *end, int *permset) { - const wchar_t *p; + const wchar_t *p = start; - if (start >= end) - return (0); - p = start; while (p < end) { switch(*p++) { case L'f': @@ -1945,11 +1934,8 @@ ismode(const char *start, const char *end, int *permset) static int is_nfs4_perms(const char *start, const char *end, int *permset) { - const char *p; + const char *p = start; - if (start >= end) - return (0); - p = start; while (p < end) { switch (*p++) { case 'r': @@ -2011,11 +1997,8 @@ is_nfs4_perms(const char *start, const char *end, int *permset) static int is_nfs4_flags(const char *start, const char *end, int *permset) { - const char *p; + const char *p = start; - if (start >= end) - return (0); - p = start; while (p < end) { switch(*p++) { case 'f': diff --git a/contrib/libarchive/libarchive/archive_entry.h b/contrib/libarchive/libarchive/archive_entry.h index 42180c4..40d6afb 100644 --- a/contrib/libarchive/libarchive/archive_entry.h +++ b/contrib/libarchive/libarchive/archive_entry.h @@ -509,6 +509,10 @@ __LA_DECL int archive_entry_acl_next_w(struct archive_entry *, int /* want_type * ARCHIVE_ENTRY_ACL_STYLE_SOLARIS - Output only one colon after "other" and * "mask" entries. * + * Flags only for archive entries with NFSv4 ACL: + * ARCHIVE_ENTRY_ACL_STYLE_COMPACT - Do not output the minus character for + * unset permissions and flags in NFSv4 ACL permission and flag fields + * * Flags for for archive entries with POSIX.1e ACL or NFSv4 ACL: * ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID - Include extra numeric ID field in * each ACL entry. @@ -519,6 +523,7 @@ __LA_DECL int archive_entry_acl_next_w(struct archive_entry *, int /* want_type #define ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 0x00000002 #define ARCHIVE_ENTRY_ACL_STYLE_SOLARIS 0x00000004 #define ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA 0x00000008 +#define ARCHIVE_ENTRY_ACL_STYLE_COMPACT 0x00000010 __LA_DECL wchar_t *archive_entry_acl_to_text_w(struct archive_entry *, ssize_t * /* len */, int /* flags */); diff --git a/contrib/libarchive/libarchive/archive_entry_acl.3 b/contrib/libarchive/libarchive/archive_entry_acl.3 index 93707d1..c5115f7 100644 --- a/contrib/libarchive/libarchive/archive_entry_acl.3 +++ b/contrib/libarchive/libarchive/archive_entry_acl.3 @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd December 27, 2016 +.Dd February 15, 2017 .Dt ARCHIVE_ENTRY_ACL 3 .Os .Sh NAME @@ -390,6 +390,13 @@ Prefix each default ACL entry with the word The mask and other ACLs don not contain a double colon. .El .Pp +The following flags are effecive only on NFSv4 ACL: +.Bl -tag -offset indent -compact -width ARCHIV +.It Dv ARCHIVE_ENTRY_ACL_STYLE_COMPACT +Do not output minus characters for unset permissions and flags in NFSv4 ACL +permission and flag fields. +.El +.Pp The following flags are effective on both POSIX.1e and NFSv4 ACL: .Bl -tag -offset indent -compact -width ARCHIV .It Dv ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID diff --git a/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c b/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c index 63aa617..ef6875f 100644 --- a/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c +++ b/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c @@ -618,9 +618,9 @@ setup_acls(struct archive_read_disk *a, /* * Translate system ACL permissions into libarchive internal structure */ -static struct { - int archive_perm; - int platform_perm; +static const struct { + const int archive_perm; + const int platform_perm; } acl_perm_map[] = { #if HAVE_SUN_ACL /* Solaris NFSv4 ACL permissions */ {ARCHIVE_ENTRY_ACL_EXECUTE, ACE_EXECUTE}, @@ -687,9 +687,9 @@ static struct { /* * Translate system NFSv4 inheritance flags into libarchive internal structure */ -static struct { - int archive_inherit; - int platform_inherit; +static const struct { + const int archive_inherit; + const int platform_inherit; } acl_inherit_map[] = { #if HAVE_SUN_ACL /* Solaris ACL inheritance flags */ {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACE_FILE_INHERIT_ACE}, @@ -882,7 +882,7 @@ sun_acl_is_trivial(acl_t *acl, mode_t mode, int *trivialp) /* * POSIX.1e ACLs marked with ACL_IS_TRIVIAL are compatible with * FreeBSD acl_is_trivial_np(). On Solaris they have 4 entries, - * incuding mask. + * including mask. */ if (acl->acl_type == ACLENT_T) { if (acl->acl_cnt == 4) diff --git a/contrib/libarchive/libarchive/archive_read_support_format_zip.c b/contrib/libarchive/libarchive/archive_read_support_format_zip.c index 53373ff..10dc14d 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_zip.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_zip.c @@ -452,26 +452,38 @@ process_extra(struct archive_read *a, const char *p, size_t extra_length, struct /* Zip64 extended information extra field. */ zip_entry->flags |= LA_USED_ZIP64; if (zip_entry->uncompressed_size == 0xffffffff) { - if (datasize < 8) - break; - zip_entry->uncompressed_size = - archive_le64dec(p + offset); + uint64_t t = 0; + if (datasize < 8 + || (t = archive_le64dec(p + offset)) > INT64_MAX) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Malformed 64-bit uncompressed size"); + return ARCHIVE_FAILED; + } + zip_entry->uncompressed_size = t; offset += 8; datasize -= 8; } if (zip_entry->compressed_size == 0xffffffff) { - if (datasize < 8) - break; - zip_entry->compressed_size = - archive_le64dec(p + offset); + uint64_t t = 0; + if (datasize < 8 + || (t = archive_le64dec(p + offset)) > INT64_MAX) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Malformed 64-bit compressed size"); + return ARCHIVE_FAILED; + } + zip_entry->compressed_size = t; offset += 8; datasize -= 8; } if (zip_entry->local_header_offset == 0xffffffff) { - if (datasize < 8) - break; - zip_entry->local_header_offset = - archive_le64dec(p + offset); + uint64_t t = 0; + if (datasize < 8 + || (t = archive_le64dec(p + offset)) > INT64_MAX) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Malformed 64-bit local header offset"); + return ARCHIVE_FAILED; + } + zip_entry->local_header_offset = t; offset += 8; datasize -= 8; } @@ -1156,11 +1168,18 @@ zip_read_data_none(struct archive_read *a, const void **_buff, || (zip->hctx_valid && zip->entry->aes_extra.vendor == AES_VENDOR_AE_2))) { if (zip->entry->flags & LA_USED_ZIP64) { + uint64_t compressed, uncompressed; zip->entry->crc32 = archive_le32dec(p + 4); - zip->entry->compressed_size = - archive_le64dec(p + 8); - zip->entry->uncompressed_size = - archive_le64dec(p + 16); + compressed = archive_le64dec(p + 8); + uncompressed = archive_le64dec(p + 16); + if (compressed > INT64_MAX || uncompressed > INT64_MAX) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Overflow of 64-bit file sizes"); + return ARCHIVE_FAILED; + } + zip->entry->compressed_size = compressed; + zip->entry->uncompressed_size = uncompressed; zip->unconsumed = 24; } else { zip->entry->crc32 = archive_le32dec(p + 4); @@ -1437,9 +1456,18 @@ zip_read_data_deflate(struct archive_read *a, const void **buff, zip->unconsumed = 4; } if (zip->entry->flags & LA_USED_ZIP64) { + uint64_t compressed, uncompressed; zip->entry->crc32 = archive_le32dec(p); - zip->entry->compressed_size = archive_le64dec(p + 4); - zip->entry->uncompressed_size = archive_le64dec(p + 12); + compressed = archive_le64dec(p + 4); + uncompressed = archive_le64dec(p + 12); + if (compressed > INT64_MAX || uncompressed > INT64_MAX) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Overflow of 64-bit file sizes"); + return ARCHIVE_FAILED; + } + zip->entry->compressed_size = compressed; + zip->entry->uncompressed_size = uncompressed; zip->unconsumed += 20; } else { zip->entry->crc32 = archive_le32dec(p); diff --git a/contrib/libarchive/libarchive/archive_write_disk_acl.c b/contrib/libarchive/libarchive/archive_write_disk_acl.c index 311aebf..144ab7e 100644 --- a/contrib/libarchive/libarchive/archive_write_disk_acl.c +++ b/contrib/libarchive/libarchive/archive_write_disk_acl.c @@ -101,7 +101,7 @@ archive_write_disk_set_acls(struct archive *a, int fd, const char *name, ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, "default"); #endif /* !HAVE_SUN_ACL */ - /* Simultaeous POSIX.1e and NFSv4 is not supported */ + /* Simultaneous POSIX.1e and NFSv4 is not supported */ return (ret); } #endif /* !HAVE_DARWIN_ACL */ @@ -119,9 +119,9 @@ archive_write_disk_set_acls(struct archive *a, int fd, const char *name, /* * Translate system ACL permissions into libarchive internal structure */ -static struct { - int archive_perm; - int platform_perm; +static const struct { + const int archive_perm; + const int platform_perm; } acl_perm_map[] = { #if HAVE_SUN_ACL /* Solaris NFSv4 ACL permissions */ {ARCHIVE_ENTRY_ACL_EXECUTE, ACE_EXECUTE}, @@ -188,9 +188,9 @@ static struct { /* * Translate system NFSv4 inheritance flags into libarchive internal structure */ -static struct { - int archive_inherit; - int platform_inherit; +static const struct { + const int archive_inherit; + const int platform_inherit; } acl_inherit_map[] = { #if HAVE_SUN_ACL /* Solaris NFSv4 inheritance flags */ {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACE_FILE_INHERIT_ACE}, diff --git a/contrib/libarchive/libarchive/archive_write_set_format_pax.c b/contrib/libarchive/libarchive/archive_write_set_format_pax.c index 1a245d7..da4fe97 100644 --- a/contrib/libarchive/libarchive/archive_write_set_format_pax.c +++ b/contrib/libarchive/libarchive/archive_write_set_format_pax.c @@ -1166,7 +1166,8 @@ archive_write_pax_header(struct archive_write *a, if ((acl_types & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) { ret = add_pax_acl(a, entry_original, pax, ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID | - ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA); + ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA | + ARCHIVE_ENTRY_ACL_STYLE_COMPACT); if (ret == ARCHIVE_FATAL) return (ARCHIVE_FATAL); } diff --git a/contrib/libarchive/libarchive/test/test_acl_pax_nfs4.tar.uu b/contrib/libarchive/libarchive/test/test_acl_pax_nfs4.tar.uu index 6a41557..ffc5cc2 100644 --- a/contrib/libarchive/libarchive/test/test_acl_pax_nfs4.tar.uu +++ b/contrib/libarchive/libarchive/test/test_acl_pax_nfs4.tar.uu @@ -1,8 +1,8 @@ begin 644 test_acl_pax_nfs4.tar M4&%X2&5A9&5R+V9I;&4````````````````````````````````````````` M```````````````````````````````````````````````````````````` -M`````````````#`P,#``````````````````````````````` +M`````````````#`P,#``````````````````````````````` M```````````````````````````````````````````````````````````` M``````````````````````````````````````````!U'`M+6%!4E=C0V]S.BTM+2TM+2TZ86QL;W``````````````````````` +M,#`P,C4V(#`P,#`P,#`P,#`P(#`Q,C`Q,@`@>``````````````````````` M```````````````````````````````````````````````````````````` M``````````````````````````````````````````````````!U#HZ9&5N>3HW."QG``````````````` +M`#`P,#`P,#`P,C8R(#`P,#`P,#`P,#`P(#`Q,C`P-P`@>``````````````` M```````````````````````````````````````````````````````````` M``````````````````````````````````````````````````````````!U M'`M+6%!4E=C0V]S.BTM+2TM+2TZ86QL;W6]N94`Z'!A05)78T-O Date: Sat, 18 Feb 2017 22:13:28 +0000 Subject: Fix incomplete merge in r313927: MFC r313572: Vendor bugfixes: cpio reader sanity fix (OSS-Fuzz 504) WARC reader sanity fixes (OSS-Fuzz 511, 526, 532, 552) mtree reader time parsing fix (OSS-Fuzz 538) XAR reader memleak fix (OSS-Fuzz 551) --- .../libarchive/archive_read_support_format_cpio.c | 10 +- .../libarchive/archive_read_support_format_mtree.c | 7 +- .../libarchive/archive_read_support_format_warc.c | 224 +++++++++++---------- .../libarchive/archive_read_support_format_xar.c | 12 ++ 4 files changed, 145 insertions(+), 108 deletions(-) diff --git a/contrib/libarchive/libarchive/archive_read_support_format_cpio.c b/contrib/libarchive/libarchive/archive_read_support_format_cpio.c index e19c711..43e6ff9 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_cpio.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_cpio.c @@ -356,7 +356,7 @@ archive_read_format_cpio_read_header(struct archive_read *a, struct archive_entry *entry) { struct cpio *cpio; - const void *h; + const void *h, *hl; struct archive_string_conv *sconv; size_t namelength; size_t name_pad; @@ -406,11 +406,11 @@ archive_read_format_cpio_read_header(struct archive_read *a, "Rejecting malformed cpio archive: symlink contents exceed 1 megabyte"); return (ARCHIVE_FATAL); } - h = __archive_read_ahead(a, + hl = __archive_read_ahead(a, (size_t)cpio->entry_bytes_remaining, NULL); - if (h == NULL) + if (hl == NULL) return (ARCHIVE_FATAL); - if (archive_entry_copy_symlink_l(entry, (const char *)h, + if (archive_entry_copy_symlink_l(entry, (const char *)hl, (size_t)cpio->entry_bytes_remaining, sconv) != 0) { if (errno == ENOMEM) { archive_set_error(&a->archive, ENOMEM, @@ -434,7 +434,7 @@ archive_read_format_cpio_read_header(struct archive_read *a, * header. XXX */ /* Compare name to "TRAILER!!!" to test for end-of-archive. */ - if (namelength == 11 && memcmp((const char *)h, "TRAILER!!!", + if (namelength == 11 && strncmp((const char *)h, "TRAILER!!!", 11) == 0) { /* TODO: Store file location of start of block. */ archive_clear_error(&a->archive); diff --git a/contrib/libarchive/libarchive/archive_read_support_format_mtree.c b/contrib/libarchive/libarchive/archive_read_support_format_mtree.c index 179f161..eb695f8 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_mtree.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_mtree.c @@ -1608,8 +1608,11 @@ parse_keyword(struct archive_read *a, struct mtree *mtree, if (*val == '.') { ++val; ns = (long)mtree_atol10(&val); - } else - ns = 0; + if (ns < 0) + ns = 0; + else if (ns > 999999999) + ns = 999999999; + } if (m > my_time_t_max) m = my_time_t_max; else if (m < my_time_t_min) diff --git a/contrib/libarchive/libarchive/archive_read_support_format_warc.c b/contrib/libarchive/libarchive/archive_read_support_format_warc.c index 30cdaf9..5e22438 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_warc.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_warc.c @@ -134,8 +134,8 @@ static ssize_t _warc_rdlen(const char *buf, size_t bsz); static time_t _warc_rdrtm(const char *buf, size_t bsz); static time_t _warc_rdmtm(const char *buf, size_t bsz); static const char *_warc_find_eoh(const char *buf, size_t bsz); +static const char *_warc_find_eol(const char *buf, size_t bsz); - int archive_read_support_format_warc(struct archive *_a) { @@ -198,8 +198,8 @@ _warc_bid(struct archive_read *a, int best_bid) /* otherwise snarf the record's version number */ ver = _warc_rdver(hdr, nrd); - if (ver == 0U || ver > 10000U) { - /* oh oh oh, best not to wager ... */ + if (ver < 1200U || ver > 10000U) { + /* we only support WARC 0.12 to 1.0 */ return -1; } @@ -254,23 +254,32 @@ start_over: &a->archive, ARCHIVE_ERRNO_MISC, "Bad record header"); return (ARCHIVE_FATAL); - } else if ((ver = _warc_rdver(buf, eoh - buf)) > 10000U) { - /* nawww, I wish they promised backward compatibility - * anyhoo, in their infinite wisdom the 28500 guys might - * come up with something we can't possibly handle so - * best end things here */ + } + ver = _warc_rdver(buf, eoh - buf); + /* we currently support WARC 0.12 to 1.0 */ + if (ver == 0U) { archive_set_error( &a->archive, ARCHIVE_ERRNO_MISC, - "Unsupported record version"); + "Invalid record version"); return (ARCHIVE_FATAL); - } else if ((cntlen = _warc_rdlen(buf, eoh - buf)) < 0) { + } else if (ver < 1200U || ver > 10000U) { + archive_set_error( + &a->archive, ARCHIVE_ERRNO_MISC, + "Unsupported record version: %u.%u", + ver / 10000, (ver % 10000) / 100); + return (ARCHIVE_FATAL); + } + cntlen = _warc_rdlen(buf, eoh - buf); + if (cntlen < 0) { /* nightmare! the specs say content-length is mandatory * so I don't feel overly bad stopping the reader here */ archive_set_error( &a->archive, EINVAL, "Bad content length"); return (ARCHIVE_FATAL); - } else if ((rtime = _warc_rdrtm(buf, eoh - buf)) == (time_t)-1) { + } + rtime = _warc_rdrtm(buf, eoh - buf); + if (rtime == (time_t)-1) { /* record time is mandatory as per WARC/1.0, * so just barf here, fast and loud */ archive_set_error( @@ -284,7 +293,7 @@ start_over: if (ver != w->pver) { /* stringify this entry's version */ archive_string_sprintf(&w->sver, - "WARC/%u.%u", ver / 10000, ver % 10000); + "WARC/%u.%u", ver / 10000, (ver % 10000) / 100); /* remember the version */ w->pver = ver; } @@ -577,51 +586,41 @@ out: } static unsigned int -_warc_rdver(const char buf[10], size_t bsz) +_warc_rdver(const char *buf, size_t bsz) { static const char magic[] = "WARC/"; - unsigned int ver; - - (void)bsz; /* UNUSED */ + unsigned int ver = 0U; + unsigned int end = 0U; - if (memcmp(buf, magic, sizeof(magic) - 1U) != 0) { - /* nope */ - return 99999U; + if (bsz < 12 || memcmp(buf, magic, sizeof(magic) - 1U) != 0) { + /* buffer too small or invalid magic */ + return ver; } /* looks good so far, read the version number for a laugh */ buf += sizeof(magic) - 1U; - /* most common case gets a quick-check here */ - if (memcmp(buf, "1.0\r\n", 5U) == 0) { - ver = 10000U; - } else { - switch (*buf) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - if (buf[1U] == '.') { - char *on; - - /* set up major version */ - ver = (buf[0U] - '0') * 10000U; - /* minor version, anyone? */ - ver += (strtol(buf + 2U, &on, 10)) * 100U; - /* don't parse anything else */ - if (on > buf + 2U) { - break; - } - } - /* FALLTHROUGH */ - case '9': - default: - /* just make the version ridiculously high */ - ver = 999999U; - break; + + if (isdigit(buf[0U]) && (buf[1U] == '.') && isdigit(buf[2U])) { + /* we support a maximum of 2 digits in the minor version */ + if (isdigit(buf[3U])) + end = 1U; + /* set up major version */ + ver = (buf[0U] - '0') * 10000U; + /* set up minor version */ + if (end == 1U) { + ver += (buf[2U] - '0') * 1000U; + ver += (buf[3U] - '0') * 100U; + } else + ver += (buf[2U] - '0') * 100U; + /* + * WARC below version 0.12 has a space-separated header + * WARC 0.12 and above terminates the version with a CRLF + */ + if (ver >= 1200U) { + if (memcmp(buf + 3U + end, "\r\n", 2U) != 0) + ver = 0U; + } else if (ver < 1200U) { + if (!isblank(*(buf + 3U + end))) + ver = 0U; } } return ver; @@ -631,34 +630,27 @@ static unsigned int _warc_rdtyp(const char *buf, size_t bsz) { static const char _key[] = "\r\nWARC-Type:"; - const char *const eob = buf + bsz; - const char *val; + const char *val, *eol; if ((val = xmemmem(buf, bsz, _key, sizeof(_key) - 1U)) == NULL) { /* no bother */ return WT_NONE; } - /* overread whitespace */ val += sizeof(_key) - 1U; - while (val < eob && isspace((unsigned char)*val)) + if ((eol = _warc_find_eol(val, buf + bsz - val)) == NULL) { + /* no end of line */ + return WT_NONE; + } + + /* overread whitespace */ + while (val < eol && isblank((unsigned char)*val)) ++val; - if (val + 8U > eob) { - ; - } else if (memcmp(val, "resource", 8U) == 0) { - return WT_RSRC; - } else if (memcmp(val, "warcinfo", 8U) == 0) { - return WT_INFO; - } else if (memcmp(val, "metadata", 8U) == 0) { - return WT_META; - } else if (memcmp(val, "request", 7U) == 0) { - return WT_REQ; - } else if (memcmp(val, "response", 8U) == 0) { - return WT_RSP; - } else if (memcmp(val, "conversi", 8U) == 0) { - return WT_CONV; - } else if (memcmp(val, "continua", 8U) == 0) { - return WT_CONT; + if (val + 8U == eol) { + if (memcmp(val, "resource", 8U) == 0) + return WT_RSRC; + else if (memcmp(val, "response", 8U) == 0) + return WT_RSP; } return WT_NONE; } @@ -667,10 +659,7 @@ static warc_string_t _warc_rduri(const char *buf, size_t bsz) { static const char _key[] = "\r\nWARC-Target-URI:"; - const char *const eob = buf + bsz; - const char *val; - const char *uri; - const char *eol; + const char *val, *uri, *eol, *p; warc_string_t res = {0U, NULL}; if ((val = xmemmem(buf, bsz, _key, sizeof(_key) - 1U)) == NULL) { @@ -679,25 +668,32 @@ _warc_rduri(const char *buf, size_t bsz) } /* overread whitespace */ val += sizeof(_key) - 1U; - while (val < eob && isspace((unsigned char)*val)) + if ((eol = _warc_find_eol(val, buf + bsz - val)) == NULL) { + /* no end of line */ + return res; + } + + while (val < eol && isblank((unsigned char)*val)) ++val; /* overread URL designators */ - if ((uri = xmemmem(val, eob - val, "://", 3U)) == NULL) { + if ((uri = xmemmem(val, eol - val, "://", 3U)) == NULL) { /* not touching that! */ return res; - } else if ((eol = memchr(uri, '\n', eob - uri)) == NULL) { - /* no end of line? :O */ - return res; } - /* massage uri to point to after :// */ + /* spaces inside uri are not allowed, CRLF should follow */ + for (p = val; p < eol; p++) { + if (isspace(*p)) + return res; + } + + /* there must be at least space for ftp */ + if (uri < (val + 3U)) + return res; + + /* move uri to point to after :// */ uri += 3U; - /* also massage eol to point to the first whitespace - * after the last non-whitespace character before - * the end of the line */ - while (eol > uri && isspace((unsigned char)eol[-1])) - --eol; /* now then, inspect the URI */ if (memcmp(val, "file", 4U) == 0) { @@ -720,7 +716,7 @@ static ssize_t _warc_rdlen(const char *buf, size_t bsz) { static const char _key[] = "\r\nContent-Length:"; - const char *val; + const char *val, *eol; char *on = NULL; long int len; @@ -728,14 +724,24 @@ _warc_rdlen(const char *buf, size_t bsz) /* no bother */ return -1; } - - /* strtol kindly overreads whitespace for us, so use that */ val += sizeof(_key) - 1U; + if ((eol = _warc_find_eol(val, buf + bsz - val)) == NULL) { + /* no end of line */ + return -1; + } + + /* skip leading whitespace */ + while (val < eol && isblank(*val)) + val++; + /* there must be at least one digit */ + if (!isdigit(*val)) + return -1; len = strtol(val, &on, 10); - if (on == NULL || !isspace((unsigned char)*on)) { - /* hm, can we trust that number? Best not. */ + if (on != eol) { + /* line must end here */ return -1; } + return (size_t)len; } @@ -743,7 +749,7 @@ static time_t _warc_rdrtm(const char *buf, size_t bsz) { static const char _key[] = "\r\nWARC-Date:"; - const char *val; + const char *val, *eol; char *on = NULL; time_t res; @@ -751,13 +757,17 @@ _warc_rdrtm(const char *buf, size_t bsz) /* no bother */ return (time_t)-1; } + val += sizeof(_key) - 1U; + if ((eol = _warc_find_eol(val, buf + bsz - val)) == NULL ) { + /* no end of line */ + return -1; + } /* xstrpisotime() kindly overreads whitespace for us, so use that */ - val += sizeof(_key) - 1U; res = xstrpisotime(val, &on); - if (on == NULL || !isspace((unsigned char)*on)) { - /* hm, can we trust that number? Best not. */ - return (time_t)-1; + if (on != eol) { + /* line must end here */ + return -1; } return res; } @@ -766,7 +776,7 @@ static time_t _warc_rdmtm(const char *buf, size_t bsz) { static const char _key[] = "\r\nLast-Modified:"; - const char *val; + const char *val, *eol; char *on = NULL; time_t res; @@ -774,13 +784,17 @@ _warc_rdmtm(const char *buf, size_t bsz) /* no bother */ return (time_t)-1; } + val += sizeof(_key) - 1U; + if ((eol = _warc_find_eol(val, buf + bsz - val)) == NULL ) { + /* no end of line */ + return -1; + } /* xstrpisotime() kindly overreads whitespace for us, so use that */ - val += sizeof(_key) - 1U; res = xstrpisotime(val, &on); - if (on == NULL || !isspace((unsigned char)*on)) { - /* hm, can we trust that number? Best not. */ - return (time_t)-1; + if (on != eol) { + /* line must end here */ + return -1; } return res; } @@ -797,4 +811,12 @@ _warc_find_eoh(const char *buf, size_t bsz) return hit; } +static const char* +_warc_find_eol(const char *buf, size_t bsz) +{ + static const char _marker[] = "\r\n"; + const char *hit = xmemmem(buf, bsz, _marker, sizeof(_marker) - 1U); + + return hit; +} /* archive_read_support_format_warc.c ends here */ diff --git a/contrib/libarchive/libarchive/archive_read_support_format_xar.c b/contrib/libarchive/libarchive/archive_read_support_format_xar.c index d3002af..7a22beb 100644 --- a/contrib/libarchive/libarchive/archive_read_support_format_xar.c +++ b/contrib/libarchive/libarchive/archive_read_support_format_xar.c @@ -394,6 +394,7 @@ static void checksum_update(struct archive_read *, const void *, size_t, const void *, size_t); static int checksum_final(struct archive_read *, const void *, size_t, const void *, size_t); +static void checksum_cleanup(struct archive_read *); static int decompression_init(struct archive_read *, enum enctype); static int decompress(struct archive_read *, const void **, size_t *, const void *, size_t *); @@ -923,6 +924,7 @@ xar_cleanup(struct archive_read *a) int r; xar = (struct xar *)(a->format->data); + checksum_cleanup(a); r = decompression_cleanup(a); hdlink = xar->hdlink_list; while (hdlink != NULL) { @@ -1720,6 +1722,16 @@ decompression_cleanup(struct archive_read *a) } static void +checksum_cleanup(struct archive_read *a) { + struct xar *xar; + + xar = (struct xar *)(a->format->data); + + _checksum_final(&(xar->a_sumwrk), NULL, 0); + _checksum_final(&(xar->e_sumwrk), NULL, 0); +} + +static void xmlattr_cleanup(struct xmlattr_list *list) { struct xmlattr *attr, *next; -- cgit v1.1 From 92720b4908dc788700697d91c50da12130ed9f7c Mon Sep 17 00:00:00 2001 From: kib Date: Sun, 19 Feb 2017 03:17:11 +0000 Subject: MFC r313797: Minor style fixes. --- sys/fs/devfs/devfs_devs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c index 288e7bc..ad7a034 100644 --- a/sys/fs/devfs/devfs_devs.c +++ b/sys/fs/devfs/devfs_devs.c @@ -208,7 +208,7 @@ devfs_newdirent(char *name, int namelen) struct dirent d; d.d_namlen = namelen; - i = sizeof (*de) + GENERIC_DIRSIZ(&d); + i = sizeof(*de) + GENERIC_DIRSIZ(&d); de = malloc(i, M_DEVFS3, M_WAITOK | M_ZERO); de->de_dirent = (struct dirent *)(de + 1); de->de_dirent->d_namlen = namelen; @@ -246,7 +246,8 @@ devfs_parent_dirent(struct devfs_dirent *de) } struct devfs_dirent * -devfs_vmkdir(struct devfs_mount *dmp, char *name, int namelen, struct devfs_dirent *dotdot, u_int inode) +devfs_vmkdir(struct devfs_mount *dmp, char *name, int namelen, + struct devfs_dirent *dotdot, u_int inode) { struct devfs_dirent *dd; struct devfs_dirent *de; -- cgit v1.1 From 32b82c0c5f9a4f91d24ec92024bf4cf2517a4615 Mon Sep 17 00:00:00 2001 From: pfg Date: Sun, 19 Feb 2017 21:10:34 +0000 Subject: MFC r313819: Remove outdated claim. Despite wishful thinking the removal of these old functions hasn't happened yet. --- include/stdlib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/stdlib.h b/include/stdlib.h index b482302..b354673 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -298,7 +298,7 @@ void srandomdev(void); long long strtonum(const char *, long long, long long, const char **); -/* Deprecated interfaces, to be removed in FreeBSD 6.0. */ +/* Deprecated interfaces, to be removed. */ __int64_t strtoq(const char *, char **, int); __uint64_t -- cgit v1.1 From 21b74cd8253268ed9118e4b3f2857d332f22f8e6 Mon Sep 17 00:00:00 2001 From: kib Date: Mon, 20 Feb 2017 10:51:46 +0000 Subject: MFC r313693: Remove MPSAFE and ARGUSED annotations, ANSI-fy syscall handlers. --- sys/vm/vm_mmap.c | 81 +++++++------------------------------------------------- 1 file changed, 10 insertions(+), 71 deletions(-) diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index b4bf117..5ac0eee 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -113,14 +113,8 @@ struct sbrk_args { }; #endif -/* - * MPSAFE - */ -/* ARGSUSED */ int -sys_sbrk(td, uap) - struct thread *td; - struct sbrk_args *uap; +sys_sbrk(struct thread *td, struct sbrk_args *uap) { /* Not yet implemented */ return (EOPNOTSUPP); @@ -132,14 +126,8 @@ struct sstk_args { }; #endif -/* - * MPSAFE - */ -/* ARGSUSED */ int -sys_sstk(td, uap) - struct thread *td; - struct sstk_args *uap; +sys_sstk(struct thread *td, struct sstk_args *uap) { /* Not yet implemented */ return (EOPNOTSUPP); @@ -153,11 +141,9 @@ struct getpagesize_args { #endif int -ogetpagesize(td, uap) - struct thread *td; - struct getpagesize_args *uap; +ogetpagesize(struct thread *td, struct getpagesize_args *uap) { - /* MP SAFE */ + td->td_retval[0] = PAGE_SIZE; return (0); } @@ -189,9 +175,6 @@ struct mmap_args { }; #endif -/* - * MPSAFE - */ int sys_mmap(td, uap) struct thread *td; @@ -519,9 +502,6 @@ struct msync_args { int flags; }; #endif -/* - * MPSAFE - */ int sys_msync(td, uap) struct thread *td; @@ -574,9 +554,6 @@ struct munmap_args { size_t len; }; #endif -/* - * MPSAFE - */ int sys_munmap(td, uap) struct thread *td; @@ -650,9 +627,6 @@ struct mprotect_args { int prot; }; #endif -/* - * MPSAFE - */ int sys_mprotect(td, uap) struct thread *td; @@ -692,13 +666,8 @@ struct minherit_args { int inherit; }; #endif -/* - * MPSAFE - */ int -sys_minherit(td, uap) - struct thread *td; - struct minherit_args *uap; +sys_minherit(struct thread *td, struct minherit_args *uap) { vm_offset_t addr; vm_size_t size, pageoff; @@ -733,13 +702,8 @@ struct madvise_args { }; #endif -/* - * MPSAFE - */ int -sys_madvise(td, uap) - struct thread *td; - struct madvise_args *uap; +sys_madvise(struct thread *td, struct madvise_args *uap) { vm_offset_t start, end; vm_map_t map; @@ -791,13 +755,8 @@ struct mincore_args { }; #endif -/* - * MPSAFE - */ int -sys_mincore(td, uap) - struct thread *td; - struct mincore_args *uap; +sys_mincore(struct thread *td, struct mincore_args *uap) { vm_offset_t addr, first_addr; vm_offset_t end, cend; @@ -1050,13 +1009,8 @@ struct mlock_args { size_t len; }; #endif -/* - * MPSAFE - */ int -sys_mlock(td, uap) - struct thread *td; - struct mlock_args *uap; +sys_mlock(struct thread *td, struct mlock_args *uap) { return (vm_mlock(td->td_proc, td->td_ucred, uap->addr, uap->len)); @@ -1122,13 +1076,8 @@ struct mlockall_args { }; #endif -/* - * MPSAFE - */ int -sys_mlockall(td, uap) - struct thread *td; - struct mlockall_args *uap; +sys_mlockall(struct thread *td, struct mlockall_args *uap) { vm_map_t map; int error; @@ -1199,13 +1148,8 @@ struct munlockall_args { }; #endif -/* - * MPSAFE - */ int -sys_munlockall(td, uap) - struct thread *td; - struct munlockall_args *uap; +sys_munlockall(struct thread *td, struct munlockall_args *uap) { vm_map_t map; int error; @@ -1240,9 +1184,6 @@ struct munlock_args { size_t len; }; #endif -/* - * MPSAFE - */ int sys_munlock(td, uap) struct thread *td; @@ -1397,8 +1338,6 @@ done: /* * vm_mmap_cdev() * - * MPSAFE - * * Helper function for vm_mmap. Perform sanity check specific for mmap * operations on cdevs. */ -- cgit v1.1 From b8d76103b6270155e56dfa26365cef5b84038733 Mon Sep 17 00:00:00 2001 From: ken Date: Mon, 20 Feb 2017 20:16:11 +0000 Subject: MFC 313895: ------------------------------------------------------------------------ r313895 | ken | 2017-02-17 13:15:27 -0700 (Fri, 17 Feb 2017) | 9 lines Make ctl(4) build with CTL_IO_DELAY defined. sys/cam/ctl/ctl.c: In ctl_datamove(), inside CTL_IO_DELAY, add a lun variable and fill it in before trying to dereference it. Sponsored by: Spectra Logic ------------------------------------------------------------------------ --- sys/cam/ctl/ctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 1b3a57f..a7ac7f9 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -12393,6 +12393,9 @@ ctl_datamove(union ctl_io *io) if (io->io_hdr.flags & CTL_FLAG_DELAY_DONE) { io->io_hdr.flags &= ~CTL_FLAG_DELAY_DONE; } else { + struct ctl_lun *lun; + + lun = CTL_LUN(io); if ((lun != NULL) && (lun->delay_info.datamove_delay > 0)) { -- cgit v1.1 From ab0aa5ccde6426fa3bbe5cab6c083e45ac5b52b4 Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 21 Feb 2017 02:18:45 +0000 Subject: MFC r312520: Integrate contrib/netbsd-tests/usr.bin/sed/t_sed.sh into the FreeBSD test suite as usr.bin/sed/sed_test Don't expect :emptybackref to fail -- it succeeds on FreeBSD Expect :preserve_leading_ws_ia to fail -- it fails on ^/stable/10, but not on ^/stable/11 or ^/head --- contrib/netbsd-tests/usr.bin/sed/t_sed.sh | 2 ++ usr.bin/sed/tests/Makefile | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/contrib/netbsd-tests/usr.bin/sed/t_sed.sh b/contrib/netbsd-tests/usr.bin/sed/t_sed.sh index c97a998..cf535a8 100755 --- a/contrib/netbsd-tests/usr.bin/sed/t_sed.sh +++ b/contrib/netbsd-tests/usr.bin/sed/t_sed.sh @@ -126,6 +126,8 @@ preserve_leading_ws_ia_head() { } preserve_leading_ws_ia_body() { + atf_expect_fail "fails on ^/stable/10" + atf_check -o inline:" 1 2 3\n4 5 6\n 7 8 9\n\n" \ -x 'echo | sed -e "/^$/i\\ 1 2 3\\ diff --git a/usr.bin/sed/tests/Makefile b/usr.bin/sed/tests/Makefile index a23d4a9..5bceaf8 100644 --- a/usr.bin/sed/tests/Makefile +++ b/usr.bin/sed/tests/Makefile @@ -1,5 +1,6 @@ # $FreeBSD$ +NETBSD_ATF_TESTS_SH+= sed_test TAP_TESTS_SH= legacy_test TAP_TESTS_SH+= multi_test TEST_METADATA.multi_test+= required_files="/usr/share/dict/words" @@ -31,7 +32,10 @@ FILES+= regress.s5.out FILES+= regress.sg.out FILES+= regress.sh FILES+= regress.y.out +ATF_TESTS_SH_SED_sed_test+= -e 's,atf_expect_fail "PR bin/28126",,g' +FILES+= d_c2048.in SUBDIR= regress.multitest.out +.include .include -- cgit v1.1 From e4a19860569883714383b6bad022a20add364d2d Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 21 Feb 2017 02:23:27 +0000 Subject: MFC r313656: Use SRCTOP to define .include with usr.bin/Makefile.inc --- usr.bin/bluetooth/Makefile.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/bluetooth/Makefile.inc b/usr.bin/bluetooth/Makefile.inc index c0e05cf..363f1e6 100644 --- a/usr.bin/bluetooth/Makefile.inc +++ b/usr.bin/bluetooth/Makefile.inc @@ -1,4 +1,4 @@ # $FreeBSD$ -.include "${.CURDIR}/../../Makefile.inc" +.include "${SRCTOP}/usr.bin/Makefile.inc" -- cgit v1.1 From 2ab2021bba43918ecec74b44b09edb987e641a04 Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 21 Feb 2017 02:24:31 +0000 Subject: MFC r313653: Use SRCTOP instead of .CURDIR relative paths with ".." This simplifies pathing in make/displayed output --- usr.bin/atm/sscop/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/atm/sscop/Makefile b/usr.bin/atm/sscop/Makefile index 36d3dcf..1ffa473 100644 --- a/usr.bin/atm/sscop/Makefile +++ b/usr.bin/atm/sscop/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -CONTRIB= ${.CURDIR}/../../../contrib/ngatm/sscop +CONTRIB= ${SRCTOP}/contrib/ngatm/sscop .PATH: ${CONTRIB} -- cgit v1.1 From 3621dc9894f03d6a0817cd541c0c581db35e7432 Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 21 Feb 2017 02:33:41 +0000 Subject: MFC r313679: Use SRCTOP/OBJTOP relative paths where possible; use :H manipulation in lieu of ../ elsewhere This simplifies pathing in make/displayed output --- usr.bin/svn/Makefile.inc | 50 ++++++++++++++++++-------------------- usr.bin/svn/svn/Makefile | 8 +++--- usr.bin/svn/svnadmin/Makefile | 8 +++--- usr.bin/svn/svnbench/Makefile | 8 +++--- usr.bin/svn/svndumpfilter/Makefile | 8 +++--- usr.bin/svn/svnfsfs/Makefile | 8 +++--- usr.bin/svn/svnlook/Makefile | 8 +++--- usr.bin/svn/svnmucc/Makefile | 8 +++--- usr.bin/svn/svnrdump/Makefile | 8 +++--- usr.bin/svn/svnserve/Makefile | 8 +++--- usr.bin/svn/svnsync/Makefile | 8 +++--- usr.bin/svn/svnversion/Makefile | 8 +++--- 12 files changed, 68 insertions(+), 70 deletions(-) diff --git a/usr.bin/svn/Makefile.inc b/usr.bin/svn/Makefile.inc index 353bb0f..15d0045 100644 --- a/usr.bin/svn/Makefile.inc +++ b/usr.bin/svn/Makefile.inc @@ -10,35 +10,33 @@ SVNLITE?= lite .if !defined(SVNDIR) -SVNDIR= ${.CURDIR}/../../../contrib/subversion/subversion -APRU= ${.CURDIR}/../../../contrib/apr-util -APR= ${.CURDIR}/../../../contrib/apr +SVNDIR= ${SRCTOP}/contrib/subversion/subversion +APRU= ${SRCTOP}/contrib/apr-util +APR= ${SRCTOP}/contrib/apr SQLITE= ${.CURDIR}/../../../contrib/sqlite3 WARNS?= 0 # definitely not warns friendly -.if exists(${.CURDIR}/../../Makefile.inc) -.include "${.CURDIR}/../../Makefile.inc" -.endif - -LIBAPRDIR= ${.OBJDIR}/../lib/libapr -LIBAPR_UTILDIR= ${.OBJDIR}/../lib/libapr_util -LIBSQLITEDIR= ${.OBJDIR}/../lib/libsqlite3 -LIBSERFDIR= ${.OBJDIR}/../lib/libserf - -LIBSVN_CLIENTDIR= ${.OBJDIR}/../lib/libsvn_client -LIBSVN_DELTADIR= ${.OBJDIR}/../lib/libsvn_delta -LIBSVN_DIFFDIR= ${.OBJDIR}/../lib/libsvn_diff -LIBSVN_FSDIR= ${.OBJDIR}/../lib/libsvn_fs -LIBSVN_FS_FSDIR= ${.OBJDIR}/../lib/libsvn_fs_fs -LIBSVN_FS_UTILDIR= ${.OBJDIR}/../lib/libsvn_fs_util -LIBSVN_FS_XDIR= ${.OBJDIR}/../lib/libsvn_fs_x -LIBSVN_RADIR= ${.OBJDIR}/../lib/libsvn_ra -LIBSVN_RA_LOCALDIR= ${.OBJDIR}/../lib/libsvn_ra_local -LIBSVN_RA_SVNDIR= ${.OBJDIR}/../lib/libsvn_ra_svn -LIBSVN_RA_SERFDIR= ${.OBJDIR}/../lib/libsvn_ra_serf -LIBSVN_REPOSDIR= ${.OBJDIR}/../lib/libsvn_repos -LIBSVN_SUBRDIR= ${.OBJDIR}/../lib/libsvn_subr -LIBSVN_WCDIR= ${.OBJDIR}/../lib/libsvn_wc +.sinclude "${.CURDIR:H:H}/Makefile.inc" + +LIBAPRDIR= ${.OBJDIR:H}/lib/libapr +LIBAPR_UTILDIR= ${.OBJDIR:H}/lib/libapr_util +LIBSQLITEDIR= ${.OBJDIR:H}/lib/libsqlite3 +LIBSERFDIR= ${.OBJDIR:H}/lib/libserf + +LIBSVN_CLIENTDIR= ${.OBJDIR:H}/lib/libsvn_client +LIBSVN_DELTADIR= ${.OBJDIR:H}/lib/libsvn_delta +LIBSVN_DIFFDIR= ${.OBJDIR:H}/lib/libsvn_diff +LIBSVN_FSDIR= ${.OBJDIR:H}/lib/libsvn_fs +LIBSVN_FS_FSDIR= ${.OBJDIR:H}/lib/libsvn_fs_fs +LIBSVN_FS_UTILDIR= ${.OBJDIR:H}/lib/libsvn_fs_util +LIBSVN_FS_XDIR= ${.OBJDIR:H}/lib/libsvn_fs_x +LIBSVN_RADIR= ${.OBJDIR:H}/lib/libsvn_ra +LIBSVN_RA_LOCALDIR= ${.OBJDIR:H}/lib/libsvn_ra_local +LIBSVN_RA_SVNDIR= ${.OBJDIR:H}/lib/libsvn_ra_svn +LIBSVN_RA_SERFDIR= ${.OBJDIR:H}/lib/libsvn_ra_serf +LIBSVN_REPOSDIR= ${.OBJDIR:H}/lib/libsvn_repos +LIBSVN_SUBRDIR= ${.OBJDIR:H}/lib/libsvn_subr +LIBSVN_WCDIR= ${.OBJDIR:H}/lib/libsvn_wc LIBAPR= ${LIBAPRDIR}/libapr.a LIBAPR_UTIL= ${LIBAPR_UTILDIR}/libapr-util.a diff --git a/usr.bin/svn/svn/Makefile b/usr.bin/svn/svn/Makefile index 3c6ac0c..174213e 100644 --- a/usr.bin/svn/svn/Makefile +++ b/usr.bin/svn/svn/Makefile @@ -2,7 +2,7 @@ MAN= -.include "${.CURDIR}/../Makefile.inc" +.include "${.CURDIR:H}/Makefile.inc" .PATH: ${SVNDIR}/svn @@ -19,11 +19,11 @@ SRCS= add-cmd.c auth-cmd.c blame-cmd.c cat-cmd.c changelist-cmd.c \ resolved-cmd.c revert-cmd.c status-cmd.c similarity.c status.c \ svn.c switch-cmd.c unlock-cmd.c update-cmd.c upgrade-cmd.c util.c -CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \ - -I${.CURDIR}/../lib/libapr \ +CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ + -I${.CURDIR:H}/lib/libapr \ -I${APR}/include/arch/unix \ -I${APR}/include \ - -I${.CURDIR}/../lib/libapr_util \ + -I${.CURDIR:H}/lib/libapr_util \ -I${APRU}/include/private \ -I${APRU}/include diff --git a/usr.bin/svn/svnadmin/Makefile b/usr.bin/svn/svnadmin/Makefile index 3b1f142..46b687f 100644 --- a/usr.bin/svn/svnadmin/Makefile +++ b/usr.bin/svn/svnadmin/Makefile @@ -2,7 +2,7 @@ MAN= -.include "${.CURDIR}/../Makefile.inc" +.include "${.CURDIR:H}/Makefile.inc" .PATH: ${SVNDIR}/svnadmin @@ -10,11 +10,11 @@ PROG= svn${SVNLITE}admin SRCS= svnadmin.c -CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \ - -I${.CURDIR}/../lib/libapr \ +CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ + -I${.CURDIR:H}/lib/libapr \ -I${APR}/include/arch/unix \ -I${APR}/include \ - -I${.CURDIR}/../lib/libapr_util \ + -I${.CURDIR:H}/lib/libapr_util \ -I${APRU}/include/private \ -I${APRU}/include diff --git a/usr.bin/svn/svnbench/Makefile b/usr.bin/svn/svnbench/Makefile index 8fb6ef8..1c4e6ad 100644 --- a/usr.bin/svn/svnbench/Makefile +++ b/usr.bin/svn/svnbench/Makefile @@ -2,7 +2,7 @@ MAN= -.include "${.CURDIR}/../Makefile.inc" +.include "${.CURDIR:H}/Makefile.inc" .PATH: ${SVNDIR}/svnbench @@ -11,11 +11,11 @@ PROG= svn${SVNLITE}bench SRCS= help-cmd.c notify.c null-blame-cmd.c null-export-cmd.c \ null-info-cmd.c null-list-cmd.c null-log-cmd.c svnbench.c util.c -CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \ - -I${.CURDIR}/../lib/libapr \ +CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ + -I${.CURDIR:H}/lib/libapr \ -I${APR}/include/arch/unix \ -I${APR}/include \ - -I${.CURDIR}/../lib/libapr_util \ + -I${.CURDIR:H}/lib/libapr_util \ -I${APRU}/include/private \ -I${APRU}/include diff --git a/usr.bin/svn/svndumpfilter/Makefile b/usr.bin/svn/svndumpfilter/Makefile index 17968a1..bbc44a4 100644 --- a/usr.bin/svn/svndumpfilter/Makefile +++ b/usr.bin/svn/svndumpfilter/Makefile @@ -2,7 +2,7 @@ MAN= -.include "${.CURDIR}/../Makefile.inc" +.include "${.CURDIR:H}/Makefile.inc" .PATH: ${SVNDIR}/svndumpfilter @@ -10,11 +10,11 @@ PROG= svn${SVNLITE}dumpfilter SRCS= svndumpfilter.c -CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \ - -I${.CURDIR}/../lib/libapr \ +CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ + -I${.CURDIR:H}/lib/libapr \ -I${APR}/include/arch/unix \ -I${APR}/include \ - -I${.CURDIR}/../lib/libapr_util \ + -I${.CURDIR:H}/lib/libapr_util \ -I${APRU}/include/private \ -I${APRU}/include diff --git a/usr.bin/svn/svnfsfs/Makefile b/usr.bin/svn/svnfsfs/Makefile index 3f056dc..416ed02 100644 --- a/usr.bin/svn/svnfsfs/Makefile +++ b/usr.bin/svn/svnfsfs/Makefile @@ -2,7 +2,7 @@ MAN= -.include "${.CURDIR}/../Makefile.inc" +.include "${.CURDIR:H}/Makefile.inc" .PATH: ${SVNDIR}/svnfsfs @@ -10,11 +10,11 @@ PROG= svn${SVNLITE}fsfs SRCS= dump-index-cmd.c load-index-cmd.c stats-cmd.c svnfsfs.c -CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \ - -I${.CURDIR}/../lib/libapr \ +CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ + -I${.CURDIR:H}/lib/libapr \ -I${APR}/include/arch/unix \ -I${APR}/include \ - -I${.CURDIR}/../lib/libapr_util \ + -I${.CURDIR:H}/lib/libapr_util \ -I${APRU}/include/private \ -I${APRU}/include diff --git a/usr.bin/svn/svnlook/Makefile b/usr.bin/svn/svnlook/Makefile index 60d4a2e..e067faf 100644 --- a/usr.bin/svn/svnlook/Makefile +++ b/usr.bin/svn/svnlook/Makefile @@ -2,7 +2,7 @@ MAN= -.include "${.CURDIR}/../Makefile.inc" +.include "${.CURDIR:H}/Makefile.inc" .PATH: ${SVNDIR}/svnlook @@ -10,11 +10,11 @@ PROG= svn${SVNLITE}look SRCS= svnlook.c -CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \ - -I${.CURDIR}/../lib/libapr \ +CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ + -I${.CURDIR:H}/lib/libapr \ -I${APR}/include/arch/unix \ -I${APR}/include \ - -I${.CURDIR}/../lib/libapr_util \ + -I${.CURDIR:H}/lib/libapr_util \ -I${APRU}/include/private \ -I${APRU}/include diff --git a/usr.bin/svn/svnmucc/Makefile b/usr.bin/svn/svnmucc/Makefile index 5beb308..d7a993a 100644 --- a/usr.bin/svn/svnmucc/Makefile +++ b/usr.bin/svn/svnmucc/Makefile @@ -2,7 +2,7 @@ MAN= -.include "${.CURDIR}/../Makefile.inc" +.include "${.CURDIR:H}/Makefile.inc" .PATH: ${SVNDIR}/svnmucc @@ -10,11 +10,11 @@ PROG= svn${SVNLITE}mucc SRCS= svnmucc.c -CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \ - -I${.CURDIR}/../lib/libapr \ +CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ + -I${.CURDIR:H}/lib/libapr \ -I${APR}/include/arch/unix \ -I${APR}/include \ - -I${.CURDIR}/../lib/libapr_util \ + -I${.CURDIR:H}/lib/libapr_util \ -I${APRU}/include/private \ -I${APRU}/include diff --git a/usr.bin/svn/svnrdump/Makefile b/usr.bin/svn/svnrdump/Makefile index b6e91ce..3c23629 100644 --- a/usr.bin/svn/svnrdump/Makefile +++ b/usr.bin/svn/svnrdump/Makefile @@ -2,7 +2,7 @@ MAN= -.include "${.CURDIR}/../Makefile.inc" +.include "${.CURDIR:H}/Makefile.inc" .PATH: ${SVNDIR}/svnrdump @@ -10,11 +10,11 @@ PROG= svn${SVNLITE}rdump SRCS= dump_editor.c load_editor.c svnrdump.c util.c -CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \ - -I${.CURDIR}/../lib/libapr \ +CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ + -I${.CURDIR:H}/lib/libapr \ -I${APR}/include/arch/unix \ -I${APR}/include \ - -I${.CURDIR}/../lib/libapr_util \ + -I${.CURDIR:H}/lib/libapr_util \ -I${APRU}/include/private \ -I${APRU}/include diff --git a/usr.bin/svn/svnserve/Makefile b/usr.bin/svn/svnserve/Makefile index 4133c27..0b475e2 100644 --- a/usr.bin/svn/svnserve/Makefile +++ b/usr.bin/svn/svnserve/Makefile @@ -2,7 +2,7 @@ MAN= -.include "${.CURDIR}/../Makefile.inc" +.include "${.CURDIR:H}/Makefile.inc" .PATH: ${SVNDIR}/svnserve @@ -10,11 +10,11 @@ PROG= svn${SVNLITE}serve SRCS= cyrus_auth.c log-escape.c logger.c serve.c svnserve.c winservice.c -CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \ - -I${.CURDIR}/../lib/libapr \ +CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ + -I${.CURDIR:H}/lib/libapr \ -I${APR}/include/arch/unix \ -I${APR}/include \ - -I${.CURDIR}/../lib/libapr_util \ + -I${.CURDIR:H}/lib/libapr_util \ -I${APRU}/include/private \ -I${APRU}/include diff --git a/usr.bin/svn/svnsync/Makefile b/usr.bin/svn/svnsync/Makefile index f6be876..60864a6 100644 --- a/usr.bin/svn/svnsync/Makefile +++ b/usr.bin/svn/svnsync/Makefile @@ -2,7 +2,7 @@ MAN= -.include "${.CURDIR}/../Makefile.inc" +.include "${.CURDIR:H}/Makefile.inc" .PATH: ${SVNDIR}/svnsync @@ -10,11 +10,11 @@ PROG= svn${SVNLITE}sync SRCS= svnsync.c sync.c -CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \ - -I${.CURDIR}/../lib/libapr \ +CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ + -I${.CURDIR:H}/lib/libapr \ -I${APR}/include/arch/unix \ -I${APR}/include \ - -I${.CURDIR}/../lib/libapr_util \ + -I${.CURDIR:H}/lib/libapr_util \ -I${APRU}/include/private \ -I${APRU}/include diff --git a/usr.bin/svn/svnversion/Makefile b/usr.bin/svn/svnversion/Makefile index b6ca826..7212c50 100644 --- a/usr.bin/svn/svnversion/Makefile +++ b/usr.bin/svn/svnversion/Makefile @@ -2,7 +2,7 @@ MAN= -.include "${.CURDIR}/../Makefile.inc" +.include "${.CURDIR:H}/Makefile.inc" .PATH: ${SVNDIR}/svnversion @@ -10,11 +10,11 @@ PROG= svn${SVNLITE}version SRCS= svnversion.c -CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \ - -I${.CURDIR}/../lib/libapr \ +CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ + -I${.CURDIR:H}/lib/libapr \ -I${APR}/include/arch/unix \ -I${APR}/include \ - -I${.CURDIR}/../lib/libapr_util \ + -I${.CURDIR:H}/lib/libapr_util \ -I${APRU}/include/private \ -I${APRU}/include -- cgit v1.1 From 5a3fdf1195b5ae2314c52f96148f683ca434045b Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 21 Feb 2017 02:34:59 +0000 Subject: MFC r313654: Use SRCTOP to refer to awk source in contrib/awk and remove unnecessary AWKSRC prefix for maketab.c The former simplifies pathing in make/displayed output, whereas the latter was just unnecessarily superfluous since .PATH referenced the path to maketab.c earlier on in the Makefile. --- usr.bin/awk/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.bin/awk/Makefile b/usr.bin/awk/Makefile index 6538636..7e4c997 100644 --- a/usr.bin/awk/Makefile +++ b/usr.bin/awk/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -AWKSRC= ${.CURDIR}/../../contrib/one-true-awk +AWKSRC= ${SRCTOP}/contrib/one-true-awk .PATH: ${AWKSRC} PROG= awk @@ -25,6 +25,6 @@ proctab.c: maketab ./maketab > proctab.c build-tools: maketab -maketab: ytab.h ${AWKSRC}/maketab.c +maketab: ytab.h maketab.c .include -- cgit v1.1 From 27565b0dff704c7701306aed25cc01aff9fcdcbc Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 21 Feb 2017 02:38:14 +0000 Subject: MFC r313652: Use SRCTOP instead of .CURDIR relative paths with ".." This simplifies pathing in make/displayed output --- usr.bin/bsdcat/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.bin/bsdcat/Makefile b/usr.bin/bsdcat/Makefile index da1c43f..f3dd812 100644 --- a/usr.bin/bsdcat/Makefile +++ b/usr.bin/bsdcat/Makefile @@ -2,10 +2,10 @@ .include -_LIBARCHIVEDIR= ${.CURDIR}/../../contrib/libarchive -_LIBARCHIVECONFDIR= ${.CURDIR}/../../lib/libarchive +_LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive +_LIBARCHIVECONFDIR= ${SRCTOP}/lib/libarchive -PROG= bsdcat +PROG= bsdcat BSDCAT_VERSION_STRING= 3.2.2 .PATH: ${_LIBARCHIVEDIR}/cat -- cgit v1.1 From acfbfe5d08cd0049c7056edd0f606472e4bd9ea2 Mon Sep 17 00:00:00 2001 From: sephe Date: Tue, 21 Feb 2017 03:00:33 +0000 Subject: MFC 311475 if: Defer the if_up until the ifnet.if_ioctl is called. This ensures the interface is initialized by the interface driver before it can be used by the rest of the system. Reviewed by: jhb, karels, gnn Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8905 --- sys/net/if.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 881cd60..67f086b 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -2266,7 +2266,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) { struct ifreq *ifr; struct ifstat *ifs; - int error = 0; + int error = 0, do_ifup = 0; int new_flags, temp_flags; size_t namelen, onamelen; size_t descrlen; @@ -2394,7 +2394,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) if_down(ifp); } else if (new_flags & IFF_UP && (ifp->if_flags & IFF_UP) == 0) { - if_up(ifp); + do_ifup = 1; } /* See if permanently promiscuous mode bit is about to flip */ if ((ifp->if_flags ^ new_flags) & IFF_PPROMISC) { @@ -2413,6 +2413,8 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) if (ifp->if_ioctl) { (void) (*ifp->if_ioctl)(ifp, cmd, data); } + if (do_ifup) + if_up(ifp); getmicrotime(&ifp->if_lastchange); break; -- cgit v1.1 From dfb3083beb054369a78ec99974a2a24b62530bc6 Mon Sep 17 00:00:00 2001 From: sephe Date: Tue, 21 Feb 2017 03:14:05 +0000 Subject: MFC 311743 hyperv: Add method to read 64bit Hyper-V specific time value. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D9057 --- sys/dev/hyperv/include/hyperv.h | 12 ++++++++++-- sys/dev/hyperv/utilities/vmbus_timesync.c | 5 ++--- sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c | 18 ++++++++++++++++-- sys/dev/hyperv/vmbus/hyperv.c | 15 +++++++++++++++ sys/dev/hyperv/vmbus/vmbus_et.c | 17 +++++++---------- 5 files changed, 50 insertions(+), 17 deletions(-) diff --git a/sys/dev/hyperv/include/hyperv.h b/sys/dev/hyperv/include/hyperv.h index 0eda9f0..f0161fc 100644 --- a/sys/dev/hyperv/include/hyperv.h +++ b/sys/dev/hyperv/include/hyperv.h @@ -79,9 +79,17 @@ struct hyperv_guid { #define HYPERV_GUID_STRLEN 40 -int hyperv_guid2str(const struct hyperv_guid *, char *, size_t); +typedef uint64_t (*hyperv_tc64_t)(void); -extern u_int hyperv_features; /* CPUID_HV_MSR_ */ +int hyperv_guid2str(const struct hyperv_guid *, char *, + size_t); + +/* + * hyperv_tc64 could be NULL, if there were no suitable Hyper-V + * specific timecounter. + */ +extern hyperv_tc64_t hyperv_tc64; +extern u_int hyperv_features; /* CPUID_HV_MSR_ */ #endif /* _KERNEL */ diff --git a/sys/dev/hyperv/utilities/vmbus_timesync.c b/sys/dev/hyperv/utilities/vmbus_timesync.c index 7610027..66b1e48 100644 --- a/sys/dev/hyperv/utilities/vmbus_timesync.c +++ b/sys/dev/hyperv/utilities/vmbus_timesync.c @@ -52,8 +52,7 @@ __FBSDID("$FreeBSD$"); VMBUS_ICVER_LE(VMBUS_IC_VERSION(4, 0), (sc)->ic_msgver) #define VMBUS_TIMESYNC_DORTT(sc) \ - (VMBUS_TIMESYNC_MSGVER4((sc)) &&\ - (hyperv_features & CPUID_HV_MSR_TIME_REFCNT)) + (VMBUS_TIMESYNC_MSGVER4((sc)) && hyperv_tc64 != NULL) static int vmbus_timesync_probe(device_t); static int vmbus_timesync_attach(device_t); @@ -117,7 +116,7 @@ vmbus_timesync(struct vmbus_ic_softc *sc, uint64_t hvtime, uint64_t sent_tc, uint64_t hv_ns, vm_ns, rtt = 0; if (VMBUS_TIMESYNC_DORTT(sc)) - rtt = rdmsr(MSR_HV_TIME_REF_COUNT) - sent_tc; + rtt = hyperv_tc64() - sent_tc; hv_ns = (hvtime - VMBUS_ICMSG_TS_BASE + rtt) * HYPERV_TIMER_NS_FACTOR; nanotime(&vm_ts); diff --git a/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c b/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c index 9caed81..118178f 100644 --- a/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c +++ b/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c @@ -118,8 +118,8 @@ hyperv_tsc_mmap(struct cdev *dev __unused, vm_ooffset_t offset, } #define HYPERV_TSC_TIMECOUNT(fence) \ -static u_int \ -hyperv_tsc_timecount_##fence(struct timecounter *tc) \ +static uint64_t \ +hyperv_tc64_tsc_##fence(void) \ { \ struct hyperv_reftsc *tsc_ref = hyperv_ref_tsc.tsc_ref; \ uint32_t seq; \ @@ -150,6 +150,13 @@ hyperv_tsc_timecount_##fence(struct timecounter *tc) \ /* Fallback to the generic timecounter, i.e. rdmsr. */ \ return (rdmsr(MSR_HV_TIME_REF_COUNT)); \ } \ + \ +static u_int \ +hyperv_tsc_timecount_##fence(struct timecounter *tc __unused) \ +{ \ + \ + return (hyperv_tc64_tsc_##fence()); \ +} \ struct __hack HYPERV_TSC_TIMECOUNT(lfence); @@ -158,6 +165,7 @@ HYPERV_TSC_TIMECOUNT(mfence); static void hyperv_tsc_tcinit(void *dummy __unused) { + hyperv_tc64_t tc64 = NULL; uint64_t val, orig; if ((hyperv_features & @@ -170,11 +178,13 @@ hyperv_tsc_tcinit(void *dummy __unused) case CPU_VENDOR_AMD: hyperv_tsc_timecounter.tc_get_timecount = hyperv_tsc_timecount_mfence; + tc64 = hyperv_tc64_tsc_mfence; break; case CPU_VENDOR_INTEL: hyperv_tsc_timecounter.tc_get_timecount = hyperv_tsc_timecount_lfence; + tc64 = hyperv_tc64_tsc_lfence; break; default: @@ -199,6 +209,10 @@ hyperv_tsc_tcinit(void *dummy __unused) /* Register "enlightened" timecounter. */ tc_init(&hyperv_tsc_timecounter); + /* Install 64 bits timecounter method for other modules to use. */ + KASSERT(tc64 != NULL, ("tc64 is not set")); + hyperv_tc64 = tc64; + /* Add device for mmap(2). */ make_dev(&hyperv_tsc_cdevsw, 0, UID_ROOT, GID_WHEEL, 0444, HYPERV_REFTSC_DEVNAME); diff --git a/sys/dev/hyperv/vmbus/hyperv.c b/sys/dev/hyperv/vmbus/hyperv.c index 2df313b..144bff5 100644 --- a/sys/dev/hyperv/vmbus/hyperv.c +++ b/sys/dev/hyperv/vmbus/hyperv.c @@ -77,6 +77,8 @@ u_int hyperv_recommends; static u_int hyperv_pm_features; static u_int hyperv_features3; +hyperv_tc64_t hyperv_tc64; + static struct timecounter hyperv_timecounter = { .tc_get_timecount = hyperv_get_timecount, .tc_poll_pps = NULL, @@ -96,6 +98,13 @@ hyperv_get_timecount(struct timecounter *tc __unused) return rdmsr(MSR_HV_TIME_REF_COUNT); } +static uint64_t +hyperv_tc64_rdmsr(void) +{ + + return (rdmsr(MSR_HV_TIME_REF_COUNT)); +} + uint64_t hypercall_post_message(bus_addr_t msg_paddr) { @@ -232,6 +241,12 @@ hyperv_init(void *dummy __unused) if (hyperv_features & CPUID_HV_MSR_TIME_REFCNT) { /* Register Hyper-V timecounter */ tc_init(&hyperv_timecounter); + + /* + * Install 64 bits timecounter method for other modules + * to use. + */ + hyperv_tc64 = hyperv_tc64_rdmsr; } } SYSINIT(hyperv_initialize, SI_SUB_HYPERVISOR, SI_ORDER_FIRST, hyperv_init, diff --git a/sys/dev/hyperv/vmbus/vmbus_et.c b/sys/dev/hyperv/vmbus/vmbus_et.c index 1e0c746..93f2ffa 100644 --- a/sys/dev/hyperv/vmbus/vmbus_et.c +++ b/sys/dev/hyperv/vmbus/vmbus_et.c @@ -50,13 +50,10 @@ __FBSDID("$FreeBSD$"); MSR_HV_STIMER_CFG_SINT_MASK) /* - * Two additionally required features: + * Additionally required feature: * - SynIC is needed for interrupt generation. - * - Time reference counter is needed to set ABS reference count to - * STIMER0_COUNT. */ -#define CPUID_HV_ET_MASK (CPUID_HV_MSR_TIME_REFCNT | \ - CPUID_HV_MSR_SYNIC | \ +#define CPUID_HV_ET_MASK (CPUID_HV_MSR_SYNIC | \ CPUID_HV_MSR_SYNTIMER) static void vmbus_et_identify(driver_t *, device_t); @@ -104,7 +101,7 @@ vmbus_et_start(struct eventtimer *et __unused, sbintime_t first, { uint64_t current; - current = rdmsr(MSR_HV_TIME_REF_COUNT); + current = hyperv_tc64(); current += hyperv_sbintime2count(first); wrmsr(MSR_HV_STIMER0_COUNT, current); @@ -133,7 +130,8 @@ vmbus_et_identify(driver_t *driver, device_t parent) { if (device_get_unit(parent) != 0 || device_find_child(parent, VMBUS_ET_NAME, -1) != NULL || - (hyperv_features & CPUID_HV_ET_MASK) != CPUID_HV_ET_MASK) + (hyperv_features & CPUID_HV_ET_MASK) != CPUID_HV_ET_MASK || + hyperv_tc64 == NULL) return; device_add_child(parent, VMBUS_ET_NAME, -1); @@ -189,9 +187,8 @@ vmbus_et_attach(device_t dev) vmbus_et.et_start = vmbus_et_start; /* - * Delay a bit to make sure that MSR_HV_TIME_REF_COUNT will - * not return 0, since writing 0 to STIMER0_COUNT will disable - * STIMER0. + * Delay a bit to make sure that hyperv_tc64 will not return 0, + * since writing 0 to STIMER0_COUNT will disable STIMER0. */ DELAY(100); smp_rendezvous(NULL, vmbus_et_config, NULL, NULL); -- cgit v1.1 From 2c373db546ea8a67318e412fcf159b0c7e645609 Mon Sep 17 00:00:00 2001 From: sephe Date: Tue, 21 Feb 2017 03:27:59 +0000 Subject: MFC 312250 alc: Add Killer E2500 support Reviewed by: jhb, yongari Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D9058 --- share/man/man4/alc.4 | 2 ++ sys/dev/alc/if_alc.c | 7 ++++++- sys/dev/alc/if_alcreg.h | 1 + sys/dev/pci/pci.c | 5 +++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/share/man/man4/alc.4 b/share/man/man4/alc.4 index 1fff8ba..b1feab5 100644 --- a/share/man/man4/alc.4 +++ b/share/man/man4/alc.4 @@ -124,6 +124,8 @@ Atheros AR8172 PCI Express Fast Ethernet controller Killer E2200 Gigabit Ethernet controller .It Killer E2400 Gigabit Ethernet controller +.It +Killer E2500 Gigabit Ethernet controller .El .Sh LOADER TUNABLES Tunables can be set at the diff --git a/sys/dev/alc/if_alc.c b/sys/dev/alc/if_alc.c index 76e4614..e789a1d 100644 --- a/sys/dev/alc/if_alc.c +++ b/sys/dev/alc/if_alc.c @@ -122,6 +122,8 @@ static struct alc_ident alc_ident_table[] = { "Killer E2200 Gigabit Ethernet" }, { VENDORID_ATHEROS, DEVICEID_ATHEROS_E2400, 9 * 1024, "Killer E2400 Gigabit Ethernet" }, + { VENDORID_ATHEROS, DEVICEID_ATHEROS_E2500, 9 * 1024, + "Killer E2500 Gigabit Ethernet" }, { 0, 0, 0, NULL} }; @@ -1082,6 +1084,7 @@ alc_phy_down(struct alc_softc *sc) case DEVICEID_ATHEROS_AR8161: case DEVICEID_ATHEROS_E2200: case DEVICEID_ATHEROS_E2400: + case DEVICEID_ATHEROS_E2500: case DEVICEID_ATHEROS_AR8162: case DEVICEID_ATHEROS_AR8171: case DEVICEID_ATHEROS_AR8172: @@ -1401,6 +1404,7 @@ alc_attach(device_t dev) switch (sc->alc_ident->deviceid) { case DEVICEID_ATHEROS_E2200: case DEVICEID_ATHEROS_E2400: + case DEVICEID_ATHEROS_E2500: sc->alc_flags |= ALC_FLAG_E2X00; /* FALLTHROUGH */ case DEVICEID_ATHEROS_AR8161: @@ -1479,7 +1483,8 @@ alc_attach(device_t dev) if (alc_dma_burst[sc->alc_dma_wr_burst] > 1024) sc->alc_dma_wr_burst = 3; /* - * Force maximum payload size to 128 bytes for E2200/E2400. + * Force maximum payload size to 128 bytes for + * E2200/E2400/E2500. * Otherwise it triggers DMA write error. */ if ((sc->alc_flags & ALC_FLAG_E2X00) != 0) diff --git a/sys/dev/alc/if_alcreg.h b/sys/dev/alc/if_alcreg.h index ae63084..29d877d 100644 --- a/sys/dev/alc/if_alcreg.h +++ b/sys/dev/alc/if_alcreg.h @@ -50,6 +50,7 @@ #define DEVICEID_ATHEROS_AR8172 0x10A0 #define DEVICEID_ATHEROS_E2200 0xE091 #define DEVICEID_ATHEROS_E2400 0xE0A1 +#define DEVICEID_ATHEROS_E2500 0xE0B1 #define ATHEROS_AR8152_B_V10 0xC0 #define ATHEROS_AR8152_B_V11 0xC1 diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 26cf526..d36f4cc 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -269,13 +269,14 @@ static const struct pci_quirk pci_quirks[] = { { 0x43851002, PCI_QUIRK_UNMAP_REG, 0x14, 0 }, /* - * Atheros AR8161/AR8162/E2200/E2400 Ethernet controllers have a - * bug that MSI interrupt does not assert if PCIM_CMD_INTxDIS bit + * Atheros AR8161/AR8162/E2200/E2400/E2500 Ethernet controllers have + * a bug that MSI interrupt does not assert if PCIM_CMD_INTxDIS bit * of the command register is set. */ { 0x10911969, PCI_QUIRK_MSI_INTX_BUG, 0, 0 }, { 0xE0911969, PCI_QUIRK_MSI_INTX_BUG, 0, 0 }, { 0xE0A11969, PCI_QUIRK_MSI_INTX_BUG, 0, 0 }, + { 0xE0B11969, PCI_QUIRK_MSI_INTX_BUG, 0, 0 }, { 0x10901969, PCI_QUIRK_MSI_INTX_BUG, 0, 0 }, /* -- cgit v1.1 From e902f09805f6f217a23eeddcbeaf7199090b20bd Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 21 Feb 2017 03:46:37 +0000 Subject: MFC r313404: Improve libnetbsd compatibility with NetBSD This change is being made to diff reduce/reduce duplication in contrib/netbsd-tests and to facilitate further porting of software from NetBSD Add the following headers: - sys/event.h: -- sys/types.h is required for kqueue on FreeBSD, but not NetBSD. - sys/types.h: -- NBBY is defined in sys/param.h on FreeBSD, not sys/types.h like on NetBSD. Pull in sys/param.h to have parity with NetBSD. - sys/wait.h: -- Define wrusage as __wrusage for parity with NetBSD typedef. - glob.h -- Define __gl_stat_t as "struct stat" for parity with NetBSD typedef. - pthread.h: -- Pull in pthread_np.h for _np functions defined separately on FreeBSD. Improve compatibility with NetBSD in the following headers: - sha1.h: -- define SHA1_CTX as SHA_CTX -- define SHA1Final as SHA1_Final - sha2.h: -- #include sha384 to pick up all of the SHA 384 bit macros and definitions. - util.h: -- Add sys/types.h to util.h to pollute the header for types used in flags_to_string and string_to_flags (u_long) as NetBSD doesn't require them for the functions. --- lib/libnetbsd/glob.h | 39 +++++++++++++++++++++++++++++++++++++++ lib/libnetbsd/pthread.h | 36 ++++++++++++++++++++++++++++++++++++ lib/libnetbsd/sha1.h | 3 +++ lib/libnetbsd/sha2.h | 1 + lib/libnetbsd/sys/event.h | 42 ++++++++++++++++++++++++++++++++++++++++++ lib/libnetbsd/sys/types.h | 37 +++++++++++++++++++++++++++++++++++++ lib/libnetbsd/sys/wait.h | 37 +++++++++++++++++++++++++++++++++++++ lib/libnetbsd/util.h | 7 ++++--- 8 files changed, 199 insertions(+), 3 deletions(-) create mode 100644 lib/libnetbsd/glob.h create mode 100644 lib/libnetbsd/pthread.h create mode 100644 lib/libnetbsd/sys/event.h create mode 100644 lib/libnetbsd/sys/types.h create mode 100644 lib/libnetbsd/sys/wait.h diff --git a/lib/libnetbsd/glob.h b/lib/libnetbsd/glob.h new file mode 100644 index 0000000..a42d823 --- /dev/null +++ b/lib/libnetbsd/glob.h @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 2017 Dell, Inc. + * 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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 _LIBNETBSD_GLOB_H_ +#define _LIBNETBSD_GLOB_H_ + +#include_next + +#ifndef __gl_stat_t +#define __gl_stat_t struct stat +#endif + +#endif diff --git a/lib/libnetbsd/pthread.h b/lib/libnetbsd/pthread.h new file mode 100644 index 0000000..f436574 --- /dev/null +++ b/lib/libnetbsd/pthread.h @@ -0,0 +1,36 @@ +/*- + * Copyright (c) 2017 Dell, Inc. + * 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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 _LIBNETBSD_PTHREAD_H_ +#define _LIBNETBSD_PTHREAD_H_ + +#include_next +#include + +#endif diff --git a/lib/libnetbsd/sha1.h b/lib/libnetbsd/sha1.h index 41280c5..9da870e 100644 --- a/lib/libnetbsd/sha1.h +++ b/lib/libnetbsd/sha1.h @@ -35,8 +35,11 @@ #include +#define SHA1_CTX SHA_CTX + #define SHA1End SHA1_End #define SHA1File SHA1_File +#define SHA1Final SHA1_Final #define SHA1Init SHA1_Init #define SHA1Update SHA1_Update diff --git a/lib/libnetbsd/sha2.h b/lib/libnetbsd/sha2.h index b67691d..6329284 100644 --- a/lib/libnetbsd/sha2.h +++ b/lib/libnetbsd/sha2.h @@ -34,6 +34,7 @@ #define _SHA2_H_ #include +#include #include #endif /* _SHA2_H_ */ diff --git a/lib/libnetbsd/sys/event.h b/lib/libnetbsd/sys/event.h new file mode 100644 index 0000000..88a363c --- /dev/null +++ b/lib/libnetbsd/sys/event.h @@ -0,0 +1,42 @@ +/*- + * Copyright (c) 2017 Dell, Inc. + * 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 REGENTS 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 REGENTS 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 _LIBNETBSD_SYS_EVENT_H_ +#define _LIBNETBSD_SYS_EVENT_H_ + +/* + * kqueue on FreeBSD requires sys/event.h, which in turn uses uintptr_t + * (defined in sys/types.h), so in order to accomodate their requirements, + * pull in sys/types.h as part of event.h. + */ +#include + +#include_next + +#endif diff --git a/lib/libnetbsd/sys/types.h b/lib/libnetbsd/sys/types.h new file mode 100644 index 0000000..e14dd49 --- /dev/null +++ b/lib/libnetbsd/sys/types.h @@ -0,0 +1,37 @@ +/*- + * Copyright (c) 2017 Dell, Inc. + * 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 REGENTS 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 REGENTS 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 _LIBNETBSD_SYS_TYPES_H_ +#define _LIBNETBSD_SYS_TYPES_H_ + +#include_next + +#include /* For NBBY */ + +#endif diff --git a/lib/libnetbsd/sys/wait.h b/lib/libnetbsd/sys/wait.h new file mode 100644 index 0000000..a936980 --- /dev/null +++ b/lib/libnetbsd/sys/wait.h @@ -0,0 +1,37 @@ +/*- + * Copyright (c) 2017 Dell, Inc. + * 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 REGENTS 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 REGENTS 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 _LIBNETBSD_SYS_WAIT_H_ +#define _LIBNETBSD_SYS_WAIT_H_ + +#include_next + +#define wrusage __wrusage + +#endif diff --git a/lib/libnetbsd/util.h b/lib/libnetbsd/util.h index c7d32e1..99bc3ca 100644 --- a/lib/libnetbsd/util.h +++ b/lib/libnetbsd/util.h @@ -30,12 +30,13 @@ * SUCH DAMAGE. */ -#ifndef _UTIL_H_ -#define _UTIL_H_ +#ifndef _LIBNETBSD_UTIL_H_ +#define _LIBNETBSD_UTIL_H_ +#include #include char *flags_to_string(u_long flags, const char *def); int string_to_flags(char **stringp, u_long *setp, u_long *clrp); -#endif /* _UTIL_H_ */ +#endif -- cgit v1.1 From 1377d3fb9ca96a7c507590e2e9e83f9a8d126d15 Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 21 Feb 2017 03:50:57 +0000 Subject: MFC r312213,r313713: r312213: Turn COMPILER_VERSION/COMPILER_TYPE make check into a compile-time check of the clang version This works around breakage on ^/stable/10 when running installworld from a ^/stable/10 host where the test wouldn't be compiled on the first go-around and would be missing when make installworld is run. PR: 208703 r313713: Handle clang 4.x+ with the compile-time exception added in r312213 It also fails the assertions noted in bug 208703 PR: 208703 PR: 217084 --- lib/msun/tests/fmaxmin_test.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/msun/tests/fmaxmin_test.c b/lib/msun/tests/fmaxmin_test.c index 7ddcc87..24056b0 100644 --- a/lib/msun/tests/fmaxmin_test.c +++ b/lib/msun/tests/fmaxmin_test.c @@ -86,6 +86,8 @@ testall_r(long double big, long double small) return (ok); } +const char *comment = NULL; + /* * Test all the functions: fmaxf, fmax, fmaxl, fminf, fmin, and fminl, * in all rounding modes and with the arguments in different orders. @@ -107,10 +109,18 @@ testall(int testnum, long double big, long double small) break; } } - printf("%sok %d - big = %.20Lg, small = %.20Lg\n", - (i == 4) ? "" : "not ", testnum, big, small); + printf("%sok %d - big = %.20Lg, small = %.20Lg%s\n", + (i == 4) ? "" : "not ", testnum, big, small, + comment == NULL ? "" : comment); } +/* Clang 3.8.0+ fails the invariants for testcase 6, 7, 10, and 11. */ +#if defined(__clang__) && \ + ((__clang_major__ > 3)) || \ + ((__clang_major__ == 3 && __clang_minor__ >= 8)) +#define affected_by_bug_208703 +#endif + int main(int argc, char *argv[]) { @@ -122,15 +132,23 @@ main(int argc, char *argv[]) testall(3, nextafterf(42.0, INFINITY), 42.0); testall(4, -5.0, -5.0); testall(5, -3.0, -4.0); +#ifdef affected_by_bug_208703 + comment = "# TODO: testcase 6-7 fails invariant with clang 3.8+ (bug 208703)"; +#endif testall(6, 1.0, NAN); testall(7, INFINITY, NAN); + comment = NULL; testall(8, INFINITY, 1.0); testall(9, -3.0, -INFINITY); testall(10, 3.0, -INFINITY); +#ifdef affected_by_bug_208703 + comment = "# TODO: testcase 11-12 fails invariant with clang 3.8+ (bug 208703)"; +#endif testall(11, NAN, NAN); /* This test isn't strictly required to work by C99. */ testall(12, 0.0, -0.0); + comment = NULL; return (0); } -- cgit v1.1 From 3a54285b0861ff79dc226ded783148832bd9bde1 Mon Sep 17 00:00:00 2001 From: mav Date: Tue, 21 Feb 2017 05:13:16 +0000 Subject: MFC r313736: Fix panic on shutdown of ramdisk LU with zero capacity. --- sys/cam/ctl/ctl_backend_ramdisk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/cam/ctl/ctl_backend_ramdisk.c b/sys/cam/ctl/ctl_backend_ramdisk.c index b743bc6..ba3fa1c 100644 --- a/sys/cam/ctl/ctl_backend_ramdisk.c +++ b/sys/cam/ctl/ctl_backend_ramdisk.c @@ -1120,8 +1120,10 @@ ctl_backend_ramdisk_create(struct ctl_be_ramdisk_softc *softc, STAILQ_INIT(&be_lun->cont_queue); sx_init(&be_lun->page_lock, "cram page lock"); - if (be_lun->cap_bytes == 0) + if (be_lun->cap_bytes == 0) { + be_lun->indir = 0; be_lun->pages = malloc(be_lun->pblocksize, M_RAMDISK, M_WAITOK); + } be_lun->zero_page = malloc(be_lun->pblocksize, M_RAMDISK, M_WAITOK|M_ZERO); mtx_init(&be_lun->queue_lock, "cram queue lock", NULL, MTX_DEF); -- cgit v1.1 From c63528b3d367dcf834ff1759cb43d40b21511c54 Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 21 Feb 2017 07:02:51 +0000 Subject: Revert r314020 The test build I ran unfortunately didn't catch the fact that the sha384.h compat header is missing on ^/stable/10 due to some code not being MFCed --- lib/libnetbsd/glob.h | 39 --------------------------------------- lib/libnetbsd/pthread.h | 36 ------------------------------------ lib/libnetbsd/sha1.h | 3 --- lib/libnetbsd/sha2.h | 1 - lib/libnetbsd/sys/event.h | 42 ------------------------------------------ lib/libnetbsd/sys/types.h | 37 ------------------------------------- lib/libnetbsd/sys/wait.h | 37 ------------------------------------- lib/libnetbsd/util.h | 7 +++---- 8 files changed, 3 insertions(+), 199 deletions(-) delete mode 100644 lib/libnetbsd/glob.h delete mode 100644 lib/libnetbsd/pthread.h delete mode 100644 lib/libnetbsd/sys/event.h delete mode 100644 lib/libnetbsd/sys/types.h delete mode 100644 lib/libnetbsd/sys/wait.h diff --git a/lib/libnetbsd/glob.h b/lib/libnetbsd/glob.h deleted file mode 100644 index a42d823..0000000 --- a/lib/libnetbsd/glob.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 2017 Dell, Inc. - * 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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 _LIBNETBSD_GLOB_H_ -#define _LIBNETBSD_GLOB_H_ - -#include_next - -#ifndef __gl_stat_t -#define __gl_stat_t struct stat -#endif - -#endif diff --git a/lib/libnetbsd/pthread.h b/lib/libnetbsd/pthread.h deleted file mode 100644 index f436574..0000000 --- a/lib/libnetbsd/pthread.h +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * Copyright (c) 2017 Dell, Inc. - * 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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 _LIBNETBSD_PTHREAD_H_ -#define _LIBNETBSD_PTHREAD_H_ - -#include_next -#include - -#endif diff --git a/lib/libnetbsd/sha1.h b/lib/libnetbsd/sha1.h index 9da870e..41280c5 100644 --- a/lib/libnetbsd/sha1.h +++ b/lib/libnetbsd/sha1.h @@ -35,11 +35,8 @@ #include -#define SHA1_CTX SHA_CTX - #define SHA1End SHA1_End #define SHA1File SHA1_File -#define SHA1Final SHA1_Final #define SHA1Init SHA1_Init #define SHA1Update SHA1_Update diff --git a/lib/libnetbsd/sha2.h b/lib/libnetbsd/sha2.h index 6329284..b67691d 100644 --- a/lib/libnetbsd/sha2.h +++ b/lib/libnetbsd/sha2.h @@ -34,7 +34,6 @@ #define _SHA2_H_ #include -#include #include #endif /* _SHA2_H_ */ diff --git a/lib/libnetbsd/sys/event.h b/lib/libnetbsd/sys/event.h deleted file mode 100644 index 88a363c..0000000 --- a/lib/libnetbsd/sys/event.h +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * Copyright (c) 2017 Dell, Inc. - * 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 REGENTS 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 REGENTS 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 _LIBNETBSD_SYS_EVENT_H_ -#define _LIBNETBSD_SYS_EVENT_H_ - -/* - * kqueue on FreeBSD requires sys/event.h, which in turn uses uintptr_t - * (defined in sys/types.h), so in order to accomodate their requirements, - * pull in sys/types.h as part of event.h. - */ -#include - -#include_next - -#endif diff --git a/lib/libnetbsd/sys/types.h b/lib/libnetbsd/sys/types.h deleted file mode 100644 index e14dd49..0000000 --- a/lib/libnetbsd/sys/types.h +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * Copyright (c) 2017 Dell, Inc. - * 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 REGENTS 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 REGENTS 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 _LIBNETBSD_SYS_TYPES_H_ -#define _LIBNETBSD_SYS_TYPES_H_ - -#include_next - -#include /* For NBBY */ - -#endif diff --git a/lib/libnetbsd/sys/wait.h b/lib/libnetbsd/sys/wait.h deleted file mode 100644 index a936980..0000000 --- a/lib/libnetbsd/sys/wait.h +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * Copyright (c) 2017 Dell, Inc. - * 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 REGENTS 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 REGENTS 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 _LIBNETBSD_SYS_WAIT_H_ -#define _LIBNETBSD_SYS_WAIT_H_ - -#include_next - -#define wrusage __wrusage - -#endif diff --git a/lib/libnetbsd/util.h b/lib/libnetbsd/util.h index 99bc3ca..c7d32e1 100644 --- a/lib/libnetbsd/util.h +++ b/lib/libnetbsd/util.h @@ -30,13 +30,12 @@ * SUCH DAMAGE. */ -#ifndef _LIBNETBSD_UTIL_H_ -#define _LIBNETBSD_UTIL_H_ +#ifndef _UTIL_H_ +#define _UTIL_H_ -#include #include char *flags_to_string(u_long flags, const char *def); int string_to_flags(char **stringp, u_long *setp, u_long *clrp); -#endif +#endif /* _UTIL_H_ */ -- cgit v1.1 From e4d106337e3471b7718aaf65dbbbfc77dc22b87a Mon Sep 17 00:00:00 2001 From: avg Date: Tue, 21 Feb 2017 08:57:27 +0000 Subject: MFC r313686: check remaining space in zfs implementations of vptocnp PR: 216939 --- .../contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c | 17 +++++++++++------ .../contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c | 4 ++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c index 9eaa7d2..9ac5fc2 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c @@ -1604,16 +1604,21 @@ zfsctl_snapshot_vptocnp(struct vop_vptocnp_args *ap) } if (sep == NULL) { mutex_exit(&sdp->sd_lock); - error = ENOENT; + error = SET_ERROR(ENOENT); } else { size_t len; len = strlen(sep->se_name); - *ap->a_buflen -= len; - bcopy(sep->se_name, ap->a_buf + *ap->a_buflen, len); - mutex_exit(&sdp->sd_lock); - vref(dvp); - *ap->a_vpp = dvp; + if (*ap->a_buflen < len) { + mutex_exit(&sdp->sd_lock); + error = SET_ERROR(ENOMEM); + } else { + *ap->a_buflen -= len; + bcopy(sep->se_name, ap->a_buf + *ap->a_buflen, len); + mutex_exit(&sdp->sd_lock); + vref(dvp); + *ap->a_vpp = dvp; + } } VN_RELE(dvp); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c index fa22523..bdab09e 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c @@ -5984,6 +5984,10 @@ zfs_vptocnp(struct vop_vptocnp_args *ap) error = zfs_znode_parent_and_name(zp, &dzp, name); if (error == 0) { len = strlen(name); + if (*ap->a_buflen < len) + error = SET_ERROR(ENOMEM); + } + if (error == 0) { *ap->a_buflen -= len; bcopy(name, ap->a_buf + *ap->a_buflen, len); *ap->a_vpp = ZTOV(dzp); -- cgit v1.1 From 24de27c91388f0d7768b2c605873c7474cfe17b7 Mon Sep 17 00:00:00 2001 From: avg Date: Tue, 21 Feb 2017 09:13:38 +0000 Subject: MFC r313687: remove l2_padding_needed statistic from zfs arc --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c index d6ccf3d..a6904de 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c @@ -709,7 +709,6 @@ typedef struct arc_stats { kstat_named_t arcstat_l2_size; kstat_named_t arcstat_l2_asize; kstat_named_t arcstat_l2_hdr_size; - kstat_named_t arcstat_l2_padding_needed; kstat_named_t arcstat_l2_write_trylock_fail; kstat_named_t arcstat_l2_write_passed_headroom; kstat_named_t arcstat_l2_write_spa_mismatch; @@ -807,7 +806,6 @@ static arc_stats_t arc_stats = { { "l2_size", KSTAT_DATA_UINT64 }, { "l2_asize", KSTAT_DATA_UINT64 }, { "l2_hdr_size", KSTAT_DATA_UINT64 }, - { "l2_padding_needed", KSTAT_DATA_UINT64 }, { "l2_write_trylock_fail", KSTAT_DATA_UINT64 }, { "l2_write_passed_headroom", KSTAT_DATA_UINT64 }, { "l2_write_spa_mismatch", KSTAT_DATA_UINT64 }, -- cgit v1.1 From 9f49c29ecbd5cfe5f5246cbafd253cbfc649a604 Mon Sep 17 00:00:00 2001 From: avg Date: Tue, 21 Feb 2017 09:29:46 +0000 Subject: MFC r313735: add svcpool_close to handle killed nfsd threads PR: 204340 Reported by: Panzura Reviewed by: rmacklem Approved by: rmacklem --- sys/fs/nfsserver/nfs_nfsdkrpc.c | 20 +++++++++----------- sys/rpc/svc.c | 42 +++++++++++++++++++++++++++++++++++++++-- sys/rpc/svc.h | 6 ++++++ 3 files changed, 55 insertions(+), 13 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdkrpc.c b/sys/fs/nfsserver/nfs_nfsdkrpc.c index 0b2333f..5c47447 100644 --- a/sys/fs/nfsserver/nfs_nfsdkrpc.c +++ b/sys/fs/nfsserver/nfs_nfsdkrpc.c @@ -554,18 +554,16 @@ nfsrvd_init(int terminating) nfsd_master_proc = NULL; NFSD_UNLOCK(); nfsrv_freeallbackchannel_xprts(); - svcpool_destroy(nfsrvd_pool); - nfsrvd_pool = NULL; + svcpool_close(nfsrvd_pool); + NFSD_LOCK(); + } else { + NFSD_UNLOCK(); + nfsrvd_pool = svcpool_create("nfsd", + SYSCTL_STATIC_CHILDREN(_vfs_nfsd)); + nfsrvd_pool->sp_rcache = NULL; + nfsrvd_pool->sp_assign = fhanew_assign; + nfsrvd_pool->sp_done = fha_nd_complete; NFSD_LOCK(); } - - NFSD_UNLOCK(); - - nfsrvd_pool = svcpool_create("nfsd", SYSCTL_STATIC_CHILDREN(_vfs_nfsd)); - nfsrvd_pool->sp_rcache = NULL; - nfsrvd_pool->sp_assign = fhanew_assign; - nfsrvd_pool->sp_done = fha_nd_complete; - - NFSD_LOCK(); } diff --git a/sys/rpc/svc.c b/sys/rpc/svc.c index ff25ee4..c6a70ea 100644 --- a/sys/rpc/svc.c +++ b/sys/rpc/svc.c @@ -75,6 +75,7 @@ static void svc_new_thread(SVCGROUP *grp); static void xprt_unregister_locked(SVCXPRT *xprt); static void svc_change_space_used(SVCPOOL *pool, long delta); static bool_t svc_request_space_available(SVCPOOL *pool); +static void svcpool_cleanup(SVCPOOL *pool); /* *************** SVCXPRT related stuff **************** */ @@ -174,8 +175,12 @@ svcpool_create(const char *name, struct sysctl_oid_list *sysctl_base) return pool; } -void -svcpool_destroy(SVCPOOL *pool) +/* + * Code common to svcpool_destroy() and svcpool_close(), which cleans up + * the pool data structures. + */ +static void +svcpool_cleanup(SVCPOOL *pool) { SVCGROUP *grp; SVCXPRT *xprt, *nxprt; @@ -211,6 +216,15 @@ svcpool_destroy(SVCPOOL *pool) mtx_lock(&pool->sp_lock); } mtx_unlock(&pool->sp_lock); +} + +void +svcpool_destroy(SVCPOOL *pool) +{ + SVCGROUP *grp; + int g; + + svcpool_cleanup(pool); for (g = 0; g < SVC_MAXGROUPS; g++) { grp = &pool->sp_groups[g]; @@ -226,6 +240,30 @@ svcpool_destroy(SVCPOOL *pool) } /* + * Similar to svcpool_destroy(), except that it does not destroy the actual + * data structures. As such, "pool" may be used again. + */ +void +svcpool_close(SVCPOOL *pool) +{ + SVCGROUP *grp; + int g; + + svcpool_cleanup(pool); + + /* Now, initialize the pool's state for a fresh svc_run() call. */ + mtx_lock(&pool->sp_lock); + pool->sp_state = SVCPOOL_INIT; + mtx_unlock(&pool->sp_lock); + for (g = 0; g < SVC_MAXGROUPS; g++) { + grp = &pool->sp_groups[g]; + mtx_lock(&grp->sg_lock); + grp->sg_state = SVCPOOL_ACTIVE; + mtx_unlock(&grp->sg_lock); + } +} + +/* * Sysctl handler to get the present thread count on a pool */ static int diff --git a/sys/rpc/svc.h b/sys/rpc/svc.h index 80285ec..2ecd1a9 100644 --- a/sys/rpc/svc.h +++ b/sys/rpc/svc.h @@ -729,6 +729,12 @@ extern SVCPOOL* svcpool_create(const char *name, extern void svcpool_destroy(SVCPOOL *pool); /* + * Close a service pool. Similar to svcpool_destroy(), but it does not + * free the data structures. As such, the pool can be used again. + */ +extern void svcpool_close(SVCPOOL *pool); + +/* * Transport independent svc_create routine. */ extern int svc_create(SVCPOOL *, void (*)(struct svc_req *, SVCXPRT *), -- cgit v1.1 From d05bf5e24a5a42fda53da526e0437363330a3151 Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 22 Feb 2017 17:57:24 +0000 Subject: MFC: r311979 Reset the EIAC register to include the LINK status bit and restore link up/down notifications. --- sys/dev/e1000/if_em.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index ff39558..c1deb90 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -5157,7 +5157,7 @@ em_enable_intr(struct adapter *adapter) u32 ims_mask = IMS_ENABLE_MASK; if (hw->mac.type == e1000_82574) { - E1000_WRITE_REG(hw, EM_EIAC, adapter->ims); + E1000_WRITE_REG(hw, EM_EIAC, EM_MSIX_MASK); ims_mask |= adapter->ims; } E1000_WRITE_REG(hw, E1000_IMS, ims_mask); -- cgit v1.1 From 2efa1535a98f7c89985bee7c9a39d33e1e15355c Mon Sep 17 00:00:00 2001 From: dexuan Date: Thu, 23 Feb 2017 06:49:46 +0000 Subject: MFC: r312685, r312686 Approved by: sephe (mentor) r312685 hyperv/hn: remember the channel pointer in struct hn_rx_ring This will be used by the coming NIC SR-IOV patch. Reviewed by: sephe Approved by: sephe (mentor) Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8909 r312686 hyperv/hn: remove the MTU and IFF_DRV_RUNNING checking in hn_rxpkt() It's unnecessary because the upper nework stack does the same checking. In the case of Hyper-V SR-IOV, we need to remove the checking because 1) multicast/broadcast packets are still received through the synthetic NIC and we need to inject the packets through the VF interface; 2) we must inject the packets even if the synthetic NIC is down, or has a different MTU from the VF device. Reviewed by: sephe Approved by: sephe (mentor) Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8962 --- sys/dev/hyperv/netvsc/if_hn.c | 11 ++--------- sys/dev/hyperv/netvsc/if_hnvar.h | 2 ++ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index 8750ab0..f7090f9 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -2118,15 +2118,7 @@ hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen, int size, do_lro = 0, do_csum = 1; int hash_type = M_HASHTYPE_OPAQUE; - if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) - return (0); - - /* - * Bail out if packet contains more data than configured MTU. - */ - if (dlen > (ifp->if_mtu + ETHER_HDR_LEN)) { - return (0); - } else if (dlen <= MHLEN) { + if (dlen <= MHLEN) { m_new = m_gethdr(M_NOWAIT, MT_DATA); if (m_new == NULL) { if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); @@ -4297,6 +4289,7 @@ hn_chan_attach(struct hn_softc *sc, struct vmbus_channel *chan) KASSERT((rxr->hn_rx_flags & HN_RX_FLAG_ATTACHED) == 0, ("RX ring %d already attached", idx)); rxr->hn_rx_flags |= HN_RX_FLAG_ATTACHED; + rxr->hn_chan = chan; if (bootverbose) { if_printf(sc->hn_ifp, "link RX ring %d to chan%u\n", diff --git a/sys/dev/hyperv/netvsc/if_hnvar.h b/sys/dev/hyperv/netvsc/if_hnvar.h index 7d5d912..5e25e8f 100644 --- a/sys/dev/hyperv/netvsc/if_hnvar.h +++ b/sys/dev/hyperv/netvsc/if_hnvar.h @@ -85,6 +85,8 @@ struct hn_rx_ring { void *hn_br; /* TX/RX bufring */ struct hyperv_dma hn_br_dma; + + struct vmbus_channel *hn_chan; } __aligned(CACHE_LINE_SIZE); #define HN_TRUST_HCSUM_IP 0x0001 -- cgit v1.1 From 801edb7982092c7fdc32ca79e679bc44e314d71f Mon Sep 17 00:00:00 2001 From: dexuan Date: Thu, 23 Feb 2017 06:57:18 +0000 Subject: MFC: r312687, r312916 Approved by: sephe (mentor) r312687 ifnet: introduce event handlers for ifup/ifdown events Hyper-V's NIC SR-IOV implementation needs a Hyper-V synthetic NIC and a VF NIC to work together, mainly to support seamless live migration. When the VF device becomes UP (or DOWN), the synthetic NIC driver needs to switch the data path from the synthetic NIC to the VF (or the opposite). So the synthetic NIC driver needs to know when a VF device is becoming UP or DOWN and hence the patch is made. Reviewed by: sephe Approved by: sephe (mentor) Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8963 r312916 ifnet: move the new ifnet_event EVENTHANDLER_DECLARE to net/if_var.h Thank glebius for pointing this out: "The network stuff shall not be added to sys/eventhandler.h" Reviewed by: David_A_Bright_DELL.com, sephe, glebius Approved by: sephe (mentor) Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D9345 --- sys/net/if.c | 2 ++ sys/net/if_var.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/sys/net/if.c b/sys/net/if.c index 67f086b..625b6d0 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -2183,6 +2183,7 @@ void if_down(struct ifnet *ifp) { + EVENTHANDLER_INVOKE(ifnet_event, ifp, IFNET_EVENT_DOWN); if_unroute(ifp, IFF_UP, AF_UNSPEC); } @@ -2195,6 +2196,7 @@ if_up(struct ifnet *ifp) { if_route(ifp, IFF_UP, AF_UNSPEC); + EVENTHANDLER_INVOKE(ifnet_event, ifp, IFNET_EVENT_UP); } /* diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 01ca26c..1456793 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -424,6 +424,11 @@ EVENTHANDLER_DECLARE(ifnet_departure_event, ifnet_departure_event_handler_t); /* Interface link state change event */ typedef void (*ifnet_link_event_handler_t)(void *, struct ifnet *, int); EVENTHANDLER_DECLARE(ifnet_link_event, ifnet_link_event_handler_t); +/* Interface up/down event */ +#define IFNET_EVENT_UP 0 +#define IFNET_EVENT_DOWN 1 +typedef void (*ifnet_event_fn)(void *, struct ifnet *ifp, int event); +EVENTHANDLER_DECLARE(ifnet_event, ifnet_event_fn); /* * interface groups -- cgit v1.1 From eacb7ed261c8a649db8cba504d96d0f0aa0c7805 Mon Sep 17 00:00:00 2001 From: dexuan Date: Thu, 23 Feb 2017 07:04:17 +0000 Subject: MFC: r312688 Approved by: sephe (mentor) r312688 hyperv/hn: add the support for VF drivers (SR-IOV) Hyper-V's NIC SR-IOV implementation needs a Hyper-V synthetic NIC and a VF NIC to work together (both NICs have the same MAC address), mainly to support seamless live migration. When the VF device becomes UP (or DOWN), the synthetic NIC driver needs to switch the data path from the synthetic NIC to the VF (or the opposite). Note: multicast/broadcast packets are still received through the synthetic NIC and we need to inject the packets through the VF interface (if the VF is UP), even if the synthetic NIC is DOWN (so we need to force the rxfilter to be NDIS_PACKET_TYPE_PROMISCUOUS, when the VF is UP). Reviewed by: sephe Approved by: sephe (mentor) Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8964 --- sys/dev/hyperv/netvsc/hn_nvs.c | 14 ++++ sys/dev/hyperv/netvsc/hn_nvs.h | 1 + sys/dev/hyperv/netvsc/if_hn.c | 170 ++++++++++++++++++++++++++++++++++++--- sys/dev/hyperv/netvsc/if_hnreg.h | 11 +++ sys/dev/hyperv/netvsc/if_hnvar.h | 5 ++ 5 files changed, 192 insertions(+), 9 deletions(-) diff --git a/sys/dev/hyperv/netvsc/hn_nvs.c b/sys/dev/hyperv/netvsc/hn_nvs.c index aa61a33..b4e9b1a 100644 --- a/sys/dev/hyperv/netvsc/hn_nvs.c +++ b/sys/dev/hyperv/netvsc/hn_nvs.c @@ -500,6 +500,8 @@ hn_nvs_conf_ndis(struct hn_softc *sc, int mtu) conf.nvs_type = HN_NVS_TYPE_NDIS_CONF; conf.nvs_mtu = mtu; conf.nvs_caps = HN_NVS_NDIS_CONF_VLAN; + if (sc->hn_nvs_ver >= HN_NVS_VERSION_5) + conf.nvs_caps |= HN_NVS_NDIS_CONF_SRIOV; /* NOTE: No response. */ error = hn_nvs_req_send(sc, &conf, sizeof(conf)); @@ -719,3 +721,15 @@ hn_nvs_send_rndis_ctrl(struct vmbus_channel *chan, return hn_nvs_send_rndis_sglist(chan, HN_NVS_RNDIS_MTYPE_CTRL, sndc, gpa, gpa_cnt); } + +void +hn_nvs_set_datapath(struct hn_softc *sc, uint32_t path) +{ + struct hn_nvs_datapath dp; + + memset(&dp, 0, sizeof(dp)); + dp.nvs_type = HN_NVS_TYPE_SET_DATAPATH; + dp.nvs_active_path = path; + + hn_nvs_req_send(sc, &dp, sizeof(dp)); +} diff --git a/sys/dev/hyperv/netvsc/hn_nvs.h b/sys/dev/hyperv/netvsc/hn_nvs.h index 49b03e0..f716abf 100644 --- a/sys/dev/hyperv/netvsc/hn_nvs.h +++ b/sys/dev/hyperv/netvsc/hn_nvs.h @@ -100,6 +100,7 @@ void hn_nvs_sent_xact(struct hn_nvs_sendctx *sndc, int hn_nvs_send_rndis_ctrl(struct vmbus_channel *chan, struct hn_nvs_sendctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); +void hn_nvs_set_datapath(struct hn_softc *sc, uint32_t path); extern struct hn_nvs_sendctx hn_nvs_sendctx_none; diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index f7090f9..b5a1da4 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -85,6 +86,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -211,6 +213,11 @@ struct hn_rxinfo { uint32_t hash_value; }; +struct hn_update_vf { + struct hn_rx_ring *rxr; + struct ifnet *vf; +}; + #define HN_RXINFO_VLAN 0x0001 #define HN_RXINFO_CSUM 0x0002 #define HN_RXINFO_HASHINF 0x0004 @@ -288,7 +295,7 @@ static int hn_txagg_pktmax_sysctl(SYSCTL_HANDLER_ARGS); static int hn_txagg_align_sysctl(SYSCTL_HANDLER_ARGS); static int hn_polling_sysctl(SYSCTL_HANDLER_ARGS); -static void hn_stop(struct hn_softc *); +static void hn_stop(struct hn_softc *, bool); static void hn_init_locked(struct hn_softc *); static int hn_chan_attach(struct hn_softc *, struct vmbus_channel *); @@ -696,7 +703,8 @@ hn_rxfilter_config(struct hn_softc *sc) HN_LOCK_ASSERT(sc); - if (ifp->if_flags & IFF_PROMISC) { + if ((ifp->if_flags & IFF_PROMISC) || + (sc->hn_flags & HN_FLAG_VF)) { filter = NDIS_PACKET_TYPE_PROMISCUOUS; } else { filter = NDIS_PACKET_TYPE_DIRECTED; @@ -883,6 +891,119 @@ hn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) ifmr->ifm_active |= IFM_10G_T | IFM_FDX; } +static void +hn_update_vf_task(void *arg, int pending __unused) +{ + struct hn_update_vf *uv = arg; + + uv->rxr->hn_vf = uv->vf; +} + +static void +hn_update_vf(struct hn_softc *sc, struct ifnet *vf) +{ + struct hn_rx_ring *rxr; + struct hn_update_vf uv; + struct task task; + int i; + + HN_LOCK_ASSERT(sc); + + TASK_INIT(&task, 0, hn_update_vf_task, &uv); + + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { + rxr = &sc->hn_rx_ring[i]; + + if (i < sc->hn_rx_ring_inuse) { + uv.rxr = rxr; + uv.vf = vf; + vmbus_chan_run_task(rxr->hn_chan, &task); + } else { + rxr->hn_vf = vf; + } + } +} + +static void +hn_set_vf(struct hn_softc *sc, struct ifnet *ifp, bool vf) +{ + struct ifnet *hn_ifp; + + HN_LOCK(sc); + + if (!(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED)) + goto out; + + hn_ifp = sc->hn_ifp; + + if (ifp == hn_ifp) + goto out; + + if (ifp->if_alloctype != IFT_ETHER) + goto out; + + /* Ignore lagg/vlan interfaces */ + if (strcmp(ifp->if_dname, "lagg") == 0 || + strcmp(ifp->if_dname, "vlan") == 0) + goto out; + + if (bcmp(IF_LLADDR(ifp), IF_LLADDR(hn_ifp), ETHER_ADDR_LEN) != 0) + goto out; + + /* Now we're sure 'ifp' is a real VF device. */ + if (vf) { + if (sc->hn_flags & HN_FLAG_VF) + goto out; + + sc->hn_flags |= HN_FLAG_VF; + hn_rxfilter_config(sc); + } else { + if (!(sc->hn_flags & HN_FLAG_VF)) + goto out; + + sc->hn_flags &= ~HN_FLAG_VF; + if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) + hn_rxfilter_config(sc); + else + hn_set_rxfilter(sc, NDIS_PACKET_TYPE_NONE); + } + + hn_nvs_set_datapath(sc, + vf ? HN_NVS_DATAPATH_VF : HN_NVS_DATAPATH_SYNTHETIC); + + hn_update_vf(sc, vf ? ifp : NULL); + + if (vf) { + hn_suspend_mgmt(sc); + sc->hn_link_flags &= + ~(HN_LINK_FLAG_LINKUP | HN_LINK_FLAG_NETCHG); + if_link_state_change(sc->hn_ifp, LINK_STATE_DOWN); + } else { + hn_resume_mgmt(sc); + } + + if (bootverbose) + if_printf(hn_ifp, "Data path is switched %s %s\n", + vf ? "to" : "from", if_name(ifp)); +out: + HN_UNLOCK(sc); +} + +static void +hn_ifnet_event(void *arg, struct ifnet *ifp, int event) +{ + if (event != IFNET_EVENT_UP && event != IFNET_EVENT_DOWN) + return; + + hn_set_vf(arg, ifp, event == IFNET_EVENT_UP); +} + +static void +hn_ifaddr_event(void *arg, struct ifnet *ifp) +{ + hn_set_vf(arg, ifp, ifp->if_flags & IFF_UP); +} + /* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */ static const struct hyperv_guid g_net_vsc_device_type = { .hv_guid = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, @@ -1204,6 +1325,12 @@ hn_attach(device_t dev) sc->hn_mgmt_taskq = sc->hn_mgmt_taskq0; hn_update_link_status(sc); + sc->hn_ifnet_evthand = EVENTHANDLER_REGISTER(ifnet_event, + hn_ifnet_event, sc, EVENTHANDLER_PRI_ANY); + + sc->hn_ifaddr_evthand = EVENTHANDLER_REGISTER(ifaddr_event, + hn_ifaddr_event, sc, EVENTHANDLER_PRI_ANY); + return (0); failed: if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) @@ -1218,6 +1345,11 @@ hn_detach(device_t dev) struct hn_softc *sc = device_get_softc(dev); struct ifnet *ifp = sc->hn_ifp; + if (sc->hn_ifaddr_evthand != NULL) + EVENTHANDLER_DEREGISTER(ifaddr_event, sc->hn_ifaddr_evthand); + if (sc->hn_ifnet_evthand != NULL) + EVENTHANDLER_DEREGISTER(ifnet_event, sc->hn_ifnet_evthand); + if (sc->hn_xact != NULL && vmbus_chan_is_revoked(sc->hn_prichan)) { /* * In case that the vmbus missed the orphan handler @@ -1230,7 +1362,7 @@ hn_detach(device_t dev) HN_LOCK(sc); if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) { if (ifp->if_drv_flags & IFF_DRV_RUNNING) - hn_stop(sc); + hn_stop(sc, true); /* * NOTE: * hn_stop() only suspends data, so managment @@ -2113,11 +2245,14 @@ static int hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen, const struct hn_rxinfo *info) { - struct ifnet *ifp = rxr->hn_ifp; + struct ifnet *ifp; struct mbuf *m_new; int size, do_lro = 0, do_csum = 1; int hash_type = M_HASHTYPE_OPAQUE; + /* If the VF is active, inject the packet through the VF */ + ifp = rxr->hn_vf ? rxr->hn_vf : rxr->hn_ifp; + if (dlen <= MHLEN) { m_new = m_gethdr(M_NOWAIT, MT_DATA); if (m_new == NULL) { @@ -2426,7 +2561,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } } else { if (ifp->if_drv_flags & IFF_DRV_RUNNING) - hn_stop(sc); + hn_stop(sc, false); } sc->hn_if_flags = ifp->if_flags; @@ -2516,7 +2651,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } static void -hn_stop(struct hn_softc *sc) +hn_stop(struct hn_softc *sc, bool detaching) { struct ifnet *ifp = sc->hn_ifp; int i; @@ -2537,6 +2672,13 @@ hn_stop(struct hn_softc *sc) atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); for (i = 0; i < sc->hn_tx_ring_inuse; ++i) sc->hn_tx_ring[i].hn_oactive = 0; + + /* + * If the VF is active, make sure the filter is not 0, even if + * the synthetic NIC is down. + */ + if (!detaching && (sc->hn_flags & HN_FLAG_VF)) + hn_rxfilter_config(sc); } static void @@ -4848,7 +4990,8 @@ hn_suspend(struct hn_softc *sc) /* Disable polling. */ hn_polling(sc, 0); - if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) + if ((sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) || + (sc->hn_flags & HN_FLAG_VF)) hn_suspend_data(sc); hn_suspend_mgmt(sc); } @@ -4937,9 +5080,18 @@ static void hn_resume(struct hn_softc *sc) { - if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) + if ((sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) || + (sc->hn_flags & HN_FLAG_VF)) hn_resume_data(sc); - hn_resume_mgmt(sc); + + /* + * When the VF is activated, the synthetic interface is changed + * to DOWN in hn_set_vf(). Here, if the VF is still active, we + * don't call hn_resume_mgmt() until the VF is deactivated in + * hn_set_vf(). + */ + if (!(sc->hn_flags & HN_FLAG_VF)) + hn_resume_mgmt(sc); /* * Re-enable polling if this interface is running and diff --git a/sys/dev/hyperv/netvsc/if_hnreg.h b/sys/dev/hyperv/netvsc/if_hnreg.h index a3b2b8b..a964b4f 100644 --- a/sys/dev/hyperv/netvsc/if_hnreg.h +++ b/sys/dev/hyperv/netvsc/if_hnreg.h @@ -133,6 +133,17 @@ struct hn_nvs_ndis_init { } __packed; CTASSERT(sizeof(struct hn_nvs_ndis_init) >= HN_NVS_REQSIZE_MIN); +#define HN_NVS_DATAPATH_SYNTHETIC 0 +#define HN_NVS_DATAPATH_VF 1 + +/* No response */ +struct hn_nvs_datapath { + uint32_t nvs_type; /* HN_NVS_TYPE_SET_DATAPATH */ + uint32_t nvs_active_path;/* HN_NVS_DATAPATH_* */ + uint32_t nvs_rsvd[6]; +} __packed; +CTASSERT(sizeof(struct hn_nvs_datapath) >= HN_NVS_REQSIZE_MIN); + struct hn_nvs_rxbuf_conn { uint32_t nvs_type; /* HN_NVS_TYPE_RXBUF_CONN */ uint32_t nvs_gpadl; /* RXBUF vmbus GPADL */ diff --git a/sys/dev/hyperv/netvsc/if_hnvar.h b/sys/dev/hyperv/netvsc/if_hnvar.h index 5e25e8f..9c39830 100644 --- a/sys/dev/hyperv/netvsc/if_hnvar.h +++ b/sys/dev/hyperv/netvsc/if_hnvar.h @@ -59,6 +59,7 @@ struct hn_tx_ring; struct hn_rx_ring { struct ifnet *hn_ifp; + struct ifnet *hn_vf; /* SR-IOV VF */ struct hn_tx_ring *hn_txr; void *hn_pktbuf; int hn_pktbuf_len; @@ -235,6 +236,9 @@ struct hn_softc { int hn_rss_ind_size; uint32_t hn_rss_hash; /* NDIS_HASH_ */ struct ndis_rssprm_toeplitz hn_rss; + + eventhandler_tag hn_ifaddr_evthand; + eventhandler_tag hn_ifnet_evthand; }; #define HN_FLAG_RXBUF_CONNECTED 0x0001 @@ -245,6 +249,7 @@ struct hn_softc { #define HN_FLAG_NO_SLEEPING 0x0020 #define HN_FLAG_RXBUF_REF 0x0040 #define HN_FLAG_CHIM_REF 0x0080 +#define HN_FLAG_VF 0x0100 #define HN_FLAG_ERRORS (HN_FLAG_RXBUF_REF | HN_FLAG_CHIM_REF) -- cgit v1.1 From d20dd8b36e7a565be7bfbb22aade51c8ffd753e9 Mon Sep 17 00:00:00 2001 From: dexuan Date: Thu, 23 Feb 2017 07:07:21 +0000 Subject: MFC r312689, r312690 Approved by: sephe (mentor) r312689 hyperv/hn: add a sysctl name for the VF interface This makes it easier for the userland script to find the releated VF interface. Reviewed by: sephe Approved by: sephe (mentor) Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D9101 r312690 hyperv/hn: add devctl_notify for VF_UP/DOWN events Reviewed by: sephe Approved by: sephe (mentor) Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D9102 --- sys/dev/hyperv/netvsc/if_hn.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index b5a1da4..8e99eef 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -294,6 +294,7 @@ static int hn_txagg_pkts_sysctl(SYSCTL_HANDLER_ARGS); static int hn_txagg_pktmax_sysctl(SYSCTL_HANDLER_ARGS); static int hn_txagg_align_sysctl(SYSCTL_HANDLER_ARGS); static int hn_polling_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_vf_sysctl(SYSCTL_HANDLER_ARGS); static void hn_stop(struct hn_softc *, bool); static void hn_init_locked(struct hn_softc *); @@ -982,6 +983,9 @@ hn_set_vf(struct hn_softc *sc, struct ifnet *ifp, bool vf) hn_resume_mgmt(sc); } + devctl_notify("HYPERV_NIC_VF", if_name(hn_ifp), + vf ? "VF_UP" : "VF_DOWN", NULL); + if (bootverbose) if_printf(hn_ifp, "Data path is switched %s %s\n", vf ? "to" : "from", if_name(ifp)); @@ -1232,6 +1236,9 @@ hn_attach(device_t dev) CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, hn_polling_sysctl, "I", "Polling frequency: [100,1000000], 0 disable polling"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "vf", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_vf_sysctl, "A", "Virtual Function's name"); /* * Setup the ifmedia, which has been initialized earlier. @@ -3205,6 +3212,22 @@ hn_rss_hash_sysctl(SYSCTL_HANDLER_ARGS) } static int +hn_vf_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + char vf_name[128]; + struct ifnet *vf; + + HN_LOCK(sc); + vf_name[0] = '\0'; + vf = sc->hn_rx_ring[0].hn_vf; + if (vf != NULL) + snprintf(vf_name, sizeof(vf_name), "%s", if_name(vf)); + HN_UNLOCK(sc); + return sysctl_handle_string(oidp, vf_name, sizeof(vf_name), req); +} + +static int hn_check_iplen(const struct mbuf *m, int hoff) { const struct ip *ip; -- cgit v1.1