mac_priv.c revision 164032
1164032Srwatson/*-
2164032Srwatson * Copyright (c) 2006 nCircle Network Security, Inc.
3164032Srwatson * All rights reserved.
4164032Srwatson *
5164032Srwatson * This software was developed by Robert N. M. Watson for the TrustedBSD
6164032Srwatson * Project under contract to nCircle Network Security, Inc.
7164032Srwatson *
8164032Srwatson * Redistribution and use in source and binary forms, with or without
9164032Srwatson * modification, are permitted provided that the following conditions
10164032Srwatson * are met:
11164032Srwatson * 1. Redistributions of source code must retain the above copyright
12164032Srwatson *    notice, this list of conditions and the following disclaimer.
13164032Srwatson * 2. Redistributions in binary form must reproduce the above copyright
14164032Srwatson *    notice, this list of conditions and the following disclaimer in the
15164032Srwatson *    documentation and/or other materials provided with the distribution.
16164032Srwatson *
17164032Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18164032Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19164032Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20164032Srwatson * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR, NCIRCLE NETWORK SECURITY,
21164032Srwatson * INC., OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22164032Srwatson * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
23164032Srwatson * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24164032Srwatson * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25164032Srwatson * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26164032Srwatson * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27164032Srwatson * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28164032Srwatson *
29164032Srwatson * $FreeBSD: head/sys/security/mac/mac_priv.c 164032 2006-11-06 13:37:19Z rwatson $
30164032Srwatson */
31164032Srwatson
32164032Srwatson/*
33164032Srwatson * MAC checks for system privileges.
34164032Srwatson */
35164032Srwatson
36164032Srwatson#include "opt_mac.h"
37164032Srwatson
38164032Srwatson#include <sys/param.h>
39164032Srwatson#include <sys/priv.h>
40164032Srwatson#include <sys/module.h>
41164032Srwatson#include <sys/mac_policy.h>
42164032Srwatson
43164032Srwatson#include <security/mac/mac_framework.h>
44164032Srwatson#include <security/mac/mac_internal.h>
45164032Srwatson
46164032Srwatsonint
47164032Srwatsonmac_priv_check(struct ucred *cred, int priv)
48164032Srwatson{
49164032Srwatson	int error;
50164032Srwatson
51164032Srwatson	MAC_CHECK(priv_check, cred, priv);
52164032Srwatson
53164032Srwatson	return (error);
54164032Srwatson}
55164032Srwatson
56164032Srwatsonint
57164032Srwatsonmac_priv_grant(struct ucred *cred, int priv)
58164032Srwatson{
59164032Srwatson	int error;
60164032Srwatson
61164032Srwatson	MAC_GRANT(priv_grant, cred, priv);
62164032Srwatson
63164032Srwatson	return (error);
64164032Srwatson}
65