1204917Sdes/*- 257429Smarkm * SPDX-License-Identifier: BSD-2-Clause 392555Sdes * 457429Smarkm * Copyright (c) 1999-2002 Robert N. M. Watson 557429Smarkm * Copyright (c) 2001-2005 Networks Associates Technology, Inc. 657429Smarkm * Copyright (c) 2005-2006 SPARTA, Inc. 757429Smarkm * All rights reserved. 857429Smarkm * 957429Smarkm * This software was developed by Robert Watson for the TrustedBSD Project. 1057429Smarkm * 1157429Smarkm * This software was developed for the FreeBSD Project in part by Network 1257429Smarkm * Associates Laboratories, the Security Research Division of Network 1357429Smarkm * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), 1457429Smarkm * as part of the DARPA CHATS research program. 1557429Smarkm * 1657429Smarkm * This software was enhanced by SPARTA ISSO under SPAWAR contract 1757429Smarkm * N66001-04-C-6019 ("SEFOS"). 1857429Smarkm * 1957429Smarkm * Redistribution and use in source and binary forms, with or without 2057429Smarkm * modification, are permitted provided that the following conditions 2157429Smarkm * are met: 2257429Smarkm * 1. Redistributions of source code must retain the above copyright 2357429Smarkm * notice, this list of conditions and the following disclaimer. 2457429Smarkm * 2. Redistributions in binary form must reproduce the above copyright 2557429Smarkm * notice, this list of conditions and the following disclaimer in the 2657429Smarkm * documentation and/or other materials provided with the distribution. 2757429Smarkm * 28162852Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 29162852Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30162852Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31162852Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 32162852Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33162852Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34162852Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35181111Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3676259Sgreen * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3776259Sgreen * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3857429Smarkm * SUCH DAMAGE. 3957429Smarkm */ 4057429Smarkm/* 4160573Skris * Userland interface for Mandatory Access Control. Loosely based on the 4276259Sgreen * POSIX.1e API. More information may be found at: 4357429Smarkm * 4492555Sdes * http://www.TrustedBSD.org/ 4592555Sdes */ 4692555Sdes 4792555Sdes#ifndef _SYS_MAC_H_ 4892555Sdes#define _SYS_MAC_H_ 4992555Sdes 5092555Sdes#ifndef _POSIX_MAC 5192555Sdes#define _POSIX_MAC 5292555Sdes#endif 53137015Sdes 54137015Sdes/* 5592555Sdes * MAC framework-related constants and limits. 5692555Sdes */ 57137015Sdes#define MAC_MAX_POLICY_NAME 32 58137015Sdes#define MAC_MAX_LABEL_ELEMENT_NAME 32 59137015Sdes#define MAC_MAX_LABEL_ELEMENT_DATA 4096 60137015Sdes#define MAC_MAX_LABEL_BUF_LEN 8192 61137015Sdes 6292555Sdes/* 6392555Sdes * struct mac is the data structure used to carry MAC labels in system calls 6492555Sdes * and ioctls between userspace and the kernel. 6592555Sdes */ 6692555Sdesstruct mac { 6792555Sdes size_t m_buflen; 6892555Sdes char *m_string; 6992555Sdes}; 7060573Skris 7157429Smarkmtypedef struct mac *mac_t; 7257429Smarkm 7357429Smarkm#ifndef _KERNEL 7460573Skris 7560573Skris/* 7660573Skris * Location of the userland MAC framework configuration file. mac.conf 7792555Sdes * set defaults for MAC-aware applications. 7892555Sdes */ 7992555Sdes#define MAC_CONFFILE "/etc/mac.conf" 8092555Sdes 81181111Sdes/* 8257429Smarkm * Extended non-POSIX.1e interfaces that offer additional services available 8360573Skris * from the userland and kernel MAC frameworks. 8492555Sdes */ 8592555Sdes__BEGIN_DECLS 8660573Skrisint mac_execve(char *fname, char **argv, char **envv, mac_t _label); 8792555Sdesint mac_free(mac_t _label); 8892555Sdesint mac_from_text(mac_t *_label, const char *_text); 8992555Sdesint mac_get_fd(int _fd, mac_t _label); 9092555Sdesint mac_get_file(const char *_path, mac_t _label); 9192555Sdesint mac_get_link(const char *_path, mac_t _label); 9292555Sdesint mac_get_peer(int _fd, mac_t _label); 9392555Sdesint mac_get_pid(pid_t _pid, mac_t _label); 9492555Sdesint mac_get_proc(mac_t _label); 95124208Sdesint mac_is_present(const char *_policyname); 9692555Sdesint mac_prepare(mac_t *_label, const char *_elements); 9792555Sdesint mac_prepare_file_label(mac_t *_label); 9892555Sdesint mac_prepare_ifnet_label(mac_t *_label); 9992555Sdesint mac_prepare_process_label(mac_t *_label); 10092555Sdesint mac_prepare_type(mac_t *_label, const char *_type); 10192555Sdesint mac_set_fd(int _fildes, const mac_t _label); 10292555Sdesint mac_set_file(const char *_path, mac_t _label); 10392555Sdesint mac_set_link(const char *_path, mac_t _label); 104124208Sdesint mac_set_proc(const mac_t _label); 10592555Sdesint mac_syscall(const char *_policyname, int _call, void *_arg); 10692555Sdesint mac_to_text(mac_t mac, char **_text); 10792555Sdes__END_DECLS 10892555Sdes 10960573Skris#endif /* !_KERNEL */ 11060573Skris 11160573Skris#endif /* !_SYS_MAC_H_ */ 11260573Skris