diff options
Diffstat (limited to 'tools/regression/priv/priv_vm_madv_protect.c')
-rw-r--r-- | tools/regression/priv/priv_vm_madv_protect.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/tools/regression/priv/priv_vm_madv_protect.c b/tools/regression/priv/priv_vm_madv_protect.c index 737adbf..008e531 100644 --- a/tools/regression/priv/priv_vm_madv_protect.c +++ b/tools/regression/priv/priv_vm_madv_protect.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2006 nCircle Network Security, Inc. + * Copyright (c) 2007 Robert N. M. Watson * All rights reserved. * * This software was developed by Robert N. M. Watson for the TrustedBSD @@ -30,8 +31,7 @@ */ /* - * Test that madvise(..., MADV_PROTECT) requires privilege by running it first - * with privilege, then again without. + * Test that madvise(..., MADV_PROTECT) requires privilege. */ #include <sys/types.h> @@ -43,22 +43,34 @@ #include "main.h" +int +priv_vm_madv_protect_setup(int asroot, int injail, struct test *test) +{ + + return (0); +} + void -priv_vm_madv_protect(void) +priv_vm_madv_protect(int asroot, int injail, struct test *test) { int error; - assert_root(); - error = madvise(NULL, 0, MADV_PROTECT); - if (error) - err(-1, "madvise(..., MADV_PROTECT) as root"); + if (asroot && injail) + expect("priv_vm_madv_protect(asroot, injail)", error, -1, + EPERM); + if (asroot && !injail) + expect("priv_vm_madv_protect(asroot, !injail", error, 0, 0); + if (!asroot && injail) + expect("priv_vm_madv_protect(!asroot, injail", error, -1, + EPERM); + if (!asroot && !injail) + expect("priv_vm_madv_protect(!asroot, !injail", error, -1, + EPERM); +} - set_euid(UID_OTHER); +void +priv_vm_madv_protect_cleanup(int asroot, int injail, struct test *test) +{ - error = madvise(NULL, 0, MADV_PROTECT); - if (error == 0) - errx(-1, "mlock as !root succeeded"); - if (errno != EPERM) - err(-1, "mlock as !root wrong errno %d", errno); } |