Module Name:    src
Committed By:   kamil
Date:           Sun Nov  6 21:47:53 UTC 2016

Modified Files:
        src/tests/kernel: t_ptrace.c

Log Message:
Run the attach_pid1 test (from t_ptrace) in unprivileged mode

Add in ATF_TC_HEAD() of attach_pid1 the following code to run it as
non-root: atf_tc_set_md_var(tc, "require.user", "unprivileged");

Solution pointed out by Nicolas Joly.

Sponsored by <The NetBSD Foundation>.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/kernel/t_ptrace.c

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

Modified files:

Index: src/tests/kernel/t_ptrace.c
diff -u src/tests/kernel/t_ptrace.c:1.11 src/tests/kernel/t_ptrace.c:1.12
--- src/tests/kernel/t_ptrace.c:1.11	Sun Nov  6 16:24:16 2016
+++ src/tests/kernel/t_ptrace.c	Sun Nov  6 21:47:53 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace.c,v 1.11 2016/11/06 16:24:16 kamil Exp $	*/
+/*	$NetBSD: t_ptrace.c,v 1.12 2016/11/06 21:47:53 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace.c,v 1.11 2016/11/06 16:24:16 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace.c,v 1.12 2016/11/06 21:47:53 kamil Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -641,13 +641,12 @@ 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)
 {
-	if (getuid() == 0)
-		atf_tc_skip("Test must be run as non-root");
-
 	errno = 0;
 	ATF_REQUIRE(ptrace(PT_ATTACH, 1, NULL, 0) == -1);
 	ATF_REQUIRE(errno == EPERM);

Reply via email to