Module Name:    src
Committed By:   jruoho
Date:           Tue Jun 30 14:30:50 UTC 2020

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/etc/mtree: NetBSD.dist.tests
        src/tests/usr.sbin: Makefile
Added Files:
        src/tests/usr.sbin/execsnoop: Makefile t_execsnoop.sh
        src/tests/usr.sbin/opensnoop: Makefile t_opensnoop.sh

Log Message:
Check that DTrace's execsnoop and opensnoop work (cf. PR kern/53417).


To generate a diff of this commit:
cvs rdiff -u -r1.864 -r1.865 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.169 -r1.170 src/etc/mtree/NetBSD.dist.tests
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.sbin/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.sbin/execsnoop/Makefile \
    src/tests/usr.sbin/execsnoop/t_execsnoop.sh
cvs rdiff -u -r0 -r1.1 src/tests/usr.sbin/opensnoop/Makefile \
    src/tests/usr.sbin/opensnoop/t_opensnoop.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.864 src/distrib/sets/lists/tests/mi:1.865
--- src/distrib/sets/lists/tests/mi:1.864	Tue Jun 30 11:48:20 2020
+++ src/distrib/sets/lists/tests/mi	Tue Jun 30 14:30:49 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.864 2020/06/30 11:48:20 jruoho Exp $
+# $NetBSD: mi,v 1.865 2020/06/30 14:30:49 jruoho Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4788,6 +4788,10 @@
 ./usr/tests/usr.sbin/cpuctl/Atffile		tests-usr.sbin-tests	compattestfile,atf
 ./usr/tests/usr.sbin/cpuctl/Kyuafile		tests-usr.sbin-tests	compattestfile,atf,kyua
 ./usr/tests/usr.sbin/cpuctl/t_cpuctl		tests-usr.sbin-tests	compattestfile,atf
+./usr/tests/usr.sbin/execsnoop			tests-usr.sbin-tests	compattestfile,atf
+./usr/tests/usr.sbin/execsnoop/Atffile		tests-usr.sbin-tests	compattestfile,atf
+./usr/tests/usr.sbin/execsnoop/Kyuafile		tests-usr.sbin-tests	compattestfile,atf,kyua
+./usr/tests/usr.sbin/execsnoop/t_execsnoop	tests-usr.sbin-tests	compattestfile,atf
 ./usr/tests/usr.sbin/mtree			tests-usr.sbin-tests	compattestfile,atf
 ./usr/tests/usr.sbin/mtree/Atffile		tests-usr.sbin-tests	compattestfile,atf
 ./usr/tests/usr.sbin/mtree/Kyuafile		tests-usr.sbin-tests	compattestfile,atf,kyua
@@ -4803,6 +4807,10 @@
 ./usr/tests/usr.sbin/mtree/mtree_d_create.out	tests-usr.sbin-tests	compattestfile,atf
 ./usr/tests/usr.sbin/mtree/netbsd6_d_create.out	tests-usr.sbin-tests	compattestfile,atf
 ./usr/tests/usr.sbin/mtree/t_mtree		tests-usr.sbin-tests	compattestfile,atf
+./usr/tests/usr.sbin/opensnoop			tests-usr.sbin-tests	compattestfile,atf
+./usr/tests/usr.sbin/opensnoop/Atffile		tests-usr.sbin-tests	compattestfile,atf
+./usr/tests/usr.sbin/opensnoop/Kyuafile		tests-usr.sbin-tests	compattestfile,atf,kyua
+./usr/tests/usr.sbin/opensnoop/t_opensnoop	tests-usr.sbin-tests	compattestfile,atf
 ./usr/tests/usr.sbin/stdethers			tests-usr.sbin-tests	compattestfile,atf
 ./usr/tests/usr.sbin/stdethers/Atffile		tests-usr.sbin-tests	compattestfile,atf
 ./usr/tests/usr.sbin/stdethers/Kyuafile		tests-usr.sbin-tests	compattestfile,atf,kyua

Index: src/etc/mtree/NetBSD.dist.tests
diff -u src/etc/mtree/NetBSD.dist.tests:1.169 src/etc/mtree/NetBSD.dist.tests:1.170
--- src/etc/mtree/NetBSD.dist.tests:1.169	Sat Jun 27 05:20:34 2020
+++ src/etc/mtree/NetBSD.dist.tests	Tue Jun 30 14:30:49 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: NetBSD.dist.tests,v 1.169 2020/06/27 05:20:34 jruoho Exp $
+#	$NetBSD: NetBSD.dist.tests,v 1.170 2020/06/30 14:30:49 jruoho Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -446,7 +446,9 @@
 ./usr/tests/usr.bin/ztest
 ./usr/tests/usr.sbin
 ./usr/tests/usr.sbin/cpuctl
+./usr/tests/usr.sbin/execsnoop
 ./usr/tests/usr.sbin/mtree
+./usr/tests/usr.sbin/opensnoop
 ./usr/tests/usr.sbin/stdethers
 ./usr/tests/usr.sbin/stdhosts
 ./usr/tests/usr.sbin/tcpdump

Index: src/tests/usr.sbin/Makefile
diff -u src/tests/usr.sbin/Makefile:1.5 src/tests/usr.sbin/Makefile:1.6
--- src/tests/usr.sbin/Makefile:1.5	Wed Jun 24 12:31:26 2020
+++ src/tests/usr.sbin/Makefile	Tue Jun 30 14:30:49 2020
@@ -1,8 +1,16 @@
-# $NetBSD: Makefile,v 1.5 2020/06/24 12:31:26 jruoho Exp $
+# $NetBSD: Makefile,v 1.6 2020/06/30 14:30:49 jruoho Exp $
 .include <bsd.own.mk>
 
 TESTSDIR=       ${TESTSBASE}/usr.sbin
 
-TESTS_SUBDIRS+= cpuctl mtree stdethers stdhosts tcpdump traceroute useradd
+TESTS_SUBDIRS+= cpuctl
+TESTS_SUBDIRS+= execsnoop
+TESTS_SUBDIRS+= mtree
+TESTS_SUBDIRS+= opensnoop
+TESTS_SUBDIRS+= stdethers
+TESTS_SUBDIRS+= stdhosts
+TESTS_SUBDIRS+= tcpdump
+TESTS_SUBDIRS+= traceroute
+TESTS_SUBDIRS+= useradd
 
 .include <bsd.test.mk>

Added files:

Index: src/tests/usr.sbin/execsnoop/Makefile
diff -u /dev/null src/tests/usr.sbin/execsnoop/Makefile:1.1
--- /dev/null	Tue Jun 30 14:30:50 2020
+++ src/tests/usr.sbin/execsnoop/Makefile	Tue Jun 30 14:30:49 2020
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2020/06/30 14:30:49 jruoho Exp $
+
+.include <bsd.own.mk>
+
+TESTSDIR=	${TESTSBASE}/usr.sbin/execsnoop
+TESTS_SH=	t_execsnoop
+
+.include <bsd.test.mk>
Index: src/tests/usr.sbin/execsnoop/t_execsnoop.sh
diff -u /dev/null src/tests/usr.sbin/execsnoop/t_execsnoop.sh:1.1
--- /dev/null	Tue Jun 30 14:30:50 2020
+++ src/tests/usr.sbin/execsnoop/t_execsnoop.sh	Tue Jun 30 14:30:49 2020
@@ -0,0 +1,69 @@
+# $NetBSD: t_execsnoop.sh,v 1.1 2020/06/30 14:30:49 jruoho Exp $
+#
+# Copyright (c) 2020 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Jukka Ruohonen.
+#
+# 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.
+#
+tmp="/tmp/execsnoop"
+
+atf_test_case basic cleanup
+basic_head() {
+	atf_set "require.user" "root"
+	atf_set "require.progs" "execsnoop"
+	atf_set "descr" "Test that DTrace's execsnoop works (cf. kern/53417)"
+}
+
+basic_body() {
+
+	n=10
+	atf_check -s exit:0 -o ignore -e empty -x "execsnoop > $tmp &"
+	sleep 1
+
+	while [ $n -gt 0 ]; do
+		whoami
+		n=$(expr $n - 1)
+	done
+
+	sleep 1
+	pkill -9 execsnoop
+
+	if [ ! $(cat $tmp | grep "whoami" | wc -l) -eq 10 ]; then
+		atf_fail "execsnoop does not work"
+	fi
+
+	atf_pass
+}
+
+basic_cleanup() {
+
+	if [ -f $tmp ]; then
+		rm $tmp
+	fi
+}
+
+atf_init_test_cases() {
+	atf_add_test_case basic
+}

Index: src/tests/usr.sbin/opensnoop/Makefile
diff -u /dev/null src/tests/usr.sbin/opensnoop/Makefile:1.1
--- /dev/null	Tue Jun 30 14:30:50 2020
+++ src/tests/usr.sbin/opensnoop/Makefile	Tue Jun 30 14:30:50 2020
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2020/06/30 14:30:50 jruoho Exp $
+
+.include <bsd.own.mk>
+
+TESTSDIR=	${TESTSBASE}/usr.sbin/opensnoop
+TESTS_SH=	t_opensnoop
+
+.include <bsd.test.mk>
Index: src/tests/usr.sbin/opensnoop/t_opensnoop.sh
diff -u /dev/null src/tests/usr.sbin/opensnoop/t_opensnoop.sh:1.1
--- /dev/null	Tue Jun 30 14:30:50 2020
+++ src/tests/usr.sbin/opensnoop/t_opensnoop.sh	Tue Jun 30 14:30:50 2020
@@ -0,0 +1,69 @@
+# $NetBSD: t_opensnoop.sh,v 1.1 2020/06/30 14:30:50 jruoho Exp $
+#
+# Copyright (c) 2020 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Jukka Ruohonen.
+#
+# 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.
+#
+tmp="/tmp/opensnoop"
+
+atf_test_case basic cleanup
+basic_head() {
+	atf_set "require.user" "root"
+	atf_set "require.progs" "opensnoop"
+	atf_set "descr" "Test that DTrace's opensnoop works (cf. kern/53417)"
+}
+
+basic_body() {
+
+	n=10
+	atf_check -s exit:0 -o ignore -e empty -x "opensnoop > $tmp &"
+	sleep 1
+
+	while [ $n -gt 0 ]; do
+		whoami
+		n=$(expr $n - 1)
+	done
+
+	sleep 1
+	pkill -9 opensnoop
+
+	if [ ! $(cat $tmp | grep "/etc/spwd.db" | wc -l) -eq 10 ]; then
+		atf_fail "opensnoop does not work"
+	fi
+
+	atf_pass
+}
+
+basic_cleanup() {
+
+	if [ -f $tmp ]; then
+		rm $tmp
+	fi
+}
+
+atf_init_test_cases() {
+	atf_add_test_case basic
+}

Reply via email to