summaryrefslogtreecommitdiffstats
path: root/tools/regression/priv/priv_vm_mlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/regression/priv/priv_vm_mlock.c')
-rw-r--r--tools/regression/priv/priv_vm_mlock.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/tools/regression/priv/priv_vm_mlock.c b/tools/regression/priv/priv_vm_mlock.c
index 3da06d3..5cdbc70 100644
--- a/tools/regression/priv/priv_vm_mlock.c
+++ b/tools/regression/priv/priv_vm_mlock.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 mlock() requires privilege by running it first with privilege,
- * then again without.
+ * Test that mlock() requires privilege.
*/
#include <sys/types.h>
@@ -43,22 +43,31 @@
#include "main.h"
+int
+priv_vm_mlock_setup(int asroot, int injail, struct test *test)
+{
+
+ return (0);
+}
+
void
-priv_vm_mlock(void)
+priv_vm_mlock(int asroot, int injail, struct test *test)
{
int error;
- assert_root();
-
error = mlock(&error, getpagesize());
- if (error)
- err(-1, "mlock as root");
+ if (asroot && injail)
+ expect("priv_vm_mlock(asroot, injail)", error, -1, EPERM);
+ if (asroot && !injail)
+ expect("priv_vm_mlock(asroot, !injail", error, 0, 0);
+ if (!asroot && injail)
+ expect("priv_vm_mlock(!asroot, injail", error, -1, EPERM);
+ if (!asroot && !injail)
+ expect("priv_vm_mlock(!asroot, !injail", error, -1, EPERM);
+}
- set_euid(UID_OTHER);
+void
+priv_vm_mlock_cleanup(int asroot, int injail, struct test *test)
+{
- error = mlock(&error, getpagesize());
- if (error == 0)
- errx(-1, "mlock as !root succeeded");
- if (errno != EPERM)
- err(-1, "mlock as !root wrong errno %d", errno);
}
OpenPOWER on IntegriCloud