1331722Seadler/* 2101242Srwatson * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson 3101242Srwatson * All rights reserved. 4101242Srwatson * 5101242Srwatson * This software was developed by Robert Watson for the TrustedBSD Project. 6101242Srwatson * 7101242Srwatson * Redistribution and use in source and binary forms, with or without 8101242Srwatson * modification, are permitted provided that the following conditions 9101242Srwatson * are met: 10101242Srwatson * 1. Redistributions of source code must retain the above copyright 11101242Srwatson * notice, this list of conditions and the following disclaimer. 12101242Srwatson * 2. Redistributions in binary form must reproduce the above copyright 13101242Srwatson * notice, this list of conditions and the following disclaimer in the 14101242Srwatson * documentation and/or other materials provided with the distribution. 15101242Srwatson * 3. The names of the authors may not be used to endorse or promote 16101242Srwatson * products derived from this software without specific prior written 17101242Srwatson * permission. 18101242Srwatson * 19101242Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20101242Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21101242Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22101242Srwatson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23101242Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24101242Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25101242Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26101242Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27101242Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28101242Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29101242Srwatson * SUCH DAMAGE. 30101242Srwatson */ 31101242Srwatson 32176901Srwatson#include <sys/cdefs.h> 33176901Srwatson__FBSDID("$FreeBSD$"); 34176901Srwatson 35101242Srwatson#include <sys/types.h> 36101242Srwatson#include <sys/mac.h> 37122810Srwatson#include <sys/socket.h> 38101242Srwatson 39111010Snectarextern int __mac_get_fd(int fd, struct mac *mac_p); 40111010Snectarextern int __mac_get_file(const char *path_p, struct mac *mac_p); 41111010Snectarextern int __mac_get_link(const char *path_p, struct mac *mac_p); 42111010Snectarextern int __mac_get_pid(pid_t pid, struct mac *mac_p); 43111010Snectarextern int __mac_get_proc(struct mac *mac_p); 44111010Snectar 45105698Srwatsonint 46105698Srwatsonmac_get_fd(int fd, struct mac *label) 47101242Srwatson{ 48101242Srwatson 49105698Srwatson return (__mac_get_fd(fd, label)); 50105698Srwatson} 51101242Srwatson 52105698Srwatsonint 53105698Srwatsonmac_get_file(const char *path, struct mac *label) 54105698Srwatson{ 55101242Srwatson 56105698Srwatson return (__mac_get_file(path, label)); 57101242Srwatson} 58101242Srwatson 59105698Srwatsonint 60105698Srwatsonmac_get_link(const char *path, struct mac *label) 61101242Srwatson{ 62101242Srwatson 63105698Srwatson return (__mac_get_link(path, label)); 64105698Srwatson} 65101242Srwatson 66105698Srwatsonint 67122810Srwatsonmac_get_peer(int fd, struct mac *label) 68122810Srwatson{ 69122810Srwatson socklen_t len; 70122810Srwatson 71122810Srwatson len = sizeof(*label); 72122810Srwatson return (getsockopt(fd, SOL_SOCKET, SO_PEERLABEL, label, &len)); 73122810Srwatson} 74140664Srwatson 75122810Srwatsonint 76105698Srwatsonmac_get_pid(pid_t pid, struct mac *label) 77105698Srwatson{ 78101242Srwatson 79105698Srwatson return (__mac_get_pid(pid, label)); 80101242Srwatson} 81101242Srwatson 82105698Srwatsonint 83105698Srwatsonmac_get_proc(struct mac *label) 84101242Srwatson{ 85101242Srwatson 86105698Srwatson return (__mac_get_proc(label)); 87101242Srwatson} 88