1 | /*- |
---|
2 | * Copyright (c) 1999-2002 Robert N. M. Watson |
---|
3 | * Copyright (c) 2001-2005 Networks Associates Technology, Inc. |
---|
4 | * Copyright (c) 2005-2006 SPARTA, Inc. |
---|
5 | * All rights reserved. |
---|
6 | * |
---|
7 | * This software was developed by Robert Watson for the TrustedBSD Project. |
---|
8 | * |
---|
9 | * This software was developed for the FreeBSD Project in part by Network |
---|
10 | * Associates Laboratories, the Security Research Division of Network |
---|
11 | * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), |
---|
12 | * as part of the DARPA CHATS research program. |
---|
13 | * |
---|
14 | * This software was enhanced by SPARTA ISSO under SPAWAR contract |
---|
15 | * N66001-04-C-6019 ("SEFOS"). |
---|
16 | * |
---|
17 | * Redistribution and use in source and binary forms, with or without |
---|
18 | * modification, are permitted provided that the following conditions |
---|
19 | * are met: |
---|
20 | * 1. Redistributions of source code must retain the above copyright |
---|
21 | * notice, this list of conditions and the following disclaimer. |
---|
22 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
23 | * notice, this list of conditions and the following disclaimer in the |
---|
24 | * documentation and/or other materials provided with the distribution. |
---|
25 | * |
---|
26 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
---|
27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
---|
30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
---|
32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
---|
33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
---|
34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
---|
35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
36 | * SUCH DAMAGE. |
---|
37 | * |
---|
38 | * $FreeBSD$ |
---|
39 | */ |
---|
40 | /* |
---|
41 | * Userland interface for Mandatory Access Control. Loosely based on the |
---|
42 | * POSIX.1e API. More information may be found at: |
---|
43 | * |
---|
44 | * http://www.TrustedBSD.org/ |
---|
45 | */ |
---|
46 | |
---|
47 | #ifndef _SYS_MAC_H_ |
---|
48 | #define _SYS_MAC_H_ |
---|
49 | |
---|
50 | #ifndef _POSIX_MAC |
---|
51 | #define _POSIX_MAC |
---|
52 | #endif |
---|
53 | |
---|
54 | /* |
---|
55 | * MAC framework-related constants and limits. |
---|
56 | */ |
---|
57 | #define MAC_MAX_POLICY_NAME 32 |
---|
58 | #define MAC_MAX_LABEL_ELEMENT_NAME 32 |
---|
59 | #define MAC_MAX_LABEL_ELEMENT_DATA 4096 |
---|
60 | #define MAC_MAX_LABEL_BUF_LEN 8192 |
---|
61 | |
---|
62 | /* |
---|
63 | * struct mac is the data structure used to carry MAC labels in system calls |
---|
64 | * and ioctls between userspace and the kernel. |
---|
65 | */ |
---|
66 | struct mac { |
---|
67 | size_t m_buflen; |
---|
68 | char *m_string; |
---|
69 | }; |
---|
70 | |
---|
71 | typedef struct mac *mac_t; |
---|
72 | |
---|
73 | #ifndef _KERNEL |
---|
74 | |
---|
75 | /* |
---|
76 | * Location of the userland MAC framework configuration file. mac.conf |
---|
77 | * set defaults for MAC-aware applications. |
---|
78 | */ |
---|
79 | #define MAC_CONFFILE "/etc/mac.conf" |
---|
80 | |
---|
81 | /* |
---|
82 | * Extended non-POSIX.1e interfaces that offer additional services available |
---|
83 | * from the userland and kernel MAC frameworks. |
---|
84 | */ |
---|
85 | __BEGIN_DECLS |
---|
86 | int mac_execve(char *fname, char **argv, char **envv, mac_t _label); |
---|
87 | int mac_free(mac_t _label); |
---|
88 | int mac_from_text(mac_t *_label, const char *_text); |
---|
89 | int mac_get_fd(int _fd, mac_t _label); |
---|
90 | int mac_get_file(const char *_path, mac_t _label); |
---|
91 | int mac_get_link(const char *_path, mac_t _label); |
---|
92 | int mac_get_peer(int _fd, mac_t _label); |
---|
93 | int mac_get_pid(pid_t _pid, mac_t _label); |
---|
94 | int mac_get_proc(mac_t _label); |
---|
95 | int mac_is_present(const char *_policyname); |
---|
96 | int mac_prepare(mac_t *_label, const char *_elements); |
---|
97 | int mac_prepare_file_label(mac_t *_label); |
---|
98 | int mac_prepare_ifnet_label(mac_t *_label); |
---|
99 | int mac_prepare_process_label(mac_t *_label); |
---|
100 | int mac_prepare_type(mac_t *_label, const char *_type); |
---|
101 | int mac_set_fd(int _fildes, const mac_t _label); |
---|
102 | int mac_set_file(const char *_path, mac_t _label); |
---|
103 | int mac_set_link(const char *_path, mac_t _label); |
---|
104 | int mac_set_proc(const mac_t _label); |
---|
105 | int mac_syscall(const char *_policyname, int _call, void *_arg); |
---|
106 | int mac_to_text(mac_t mac, char **_text); |
---|
107 | __END_DECLS |
---|
108 | |
---|
109 | #endif /* !_KERNEL */ |
---|
110 | |
---|
111 | #endif /* !_SYS_MAC_H_ */ |
---|