1221431Sjonathan/*- 2221431Sjonathan * Copyright (c) 2008-2011 Robert N. M. Watson 3224651Sjonathan * Copyright (c) 2011 Jonathan Anderson 4221431Sjonathan * All rights reserved. 5221431Sjonathan * 6221431Sjonathan * Redistribution and use in source and binary forms, with or without 7221431Sjonathan * modification, are permitted provided that the following conditions 8221431Sjonathan * are met: 9221431Sjonathan * 1. Redistributions of source code must retain the above copyright 10221431Sjonathan * notice, this list of conditions and the following disclaimer. 11221431Sjonathan * 2. Redistributions in binary form must reproduce the above copyright 12221431Sjonathan * notice, this list of conditions and the following disclaimer in the 13221431Sjonathan * documentation and/or other materials provided with the distribution. 14221431Sjonathan * 15221431Sjonathan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16221431Sjonathan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17221431Sjonathan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18221431Sjonathan * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19221431Sjonathan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20221431Sjonathan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21221431Sjonathan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22221431Sjonathan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23221431Sjonathan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24221431Sjonathan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25221431Sjonathan * SUCH DAMAGE. 26221431Sjonathan * 27221431Sjonathan * $FreeBSD$ 28221431Sjonathan */ 29221431Sjonathan 30221431Sjonathan/* 31221431Sjonathan * Test that various sysctls are (and aren't) available on capability mode. 32221431Sjonathan */ 33221431Sjonathan 34221431Sjonathan#include <sys/cdefs.h> 35221431Sjonathan__FBSDID("$FreeBSD$"); 36221431Sjonathan 37221431Sjonathan#include <sys/types.h> 38221431Sjonathan#include <sys/capability.h> 39224651Sjonathan#include <sys/errno.h> 40221431Sjonathan#include <sys/sysctl.h> 41221431Sjonathan#include <sys/wait.h> 42221431Sjonathan 43221431Sjonathan#include <err.h> 44221431Sjonathan#include <stdio.h> 45221431Sjonathan#include <stdlib.h> 46221431Sjonathan#include <unistd.h> 47221431Sjonathan 48221431Sjonathan#include "cap_test.h" 49221431Sjonathan 50221431Sjonathan/* 51221431Sjonathan * Certain sysctls are permitted in capability mode, but most are not. Test 52221431Sjonathan * for the ones that should be, and try one or two that shouldn't. 53221431Sjonathan */ 54224651Sjonathanint 55221431Sjonathantest_sysctl(void) 56221431Sjonathan{ 57224651Sjonathan int i, oid[2]; 58224651Sjonathan int success = PASSED; 59221431Sjonathan size_t len; 60221431Sjonathan 61221431Sjonathan oid[0] = CTL_KERN; 62221431Sjonathan oid[1] = KERN_OSRELDATE; 63221431Sjonathan len = sizeof(i); 64224651Sjonathan CHECK(sysctl(oid, 2, &i, &len, NULL, 0) == 0); 65221431Sjonathan 66224651Sjonathan return (success); 67221431Sjonathan} 68