From owner-p4-projects@FreeBSD.ORG Sun Nov 16 09:51:58 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DC34616A4D0; Sun, 16 Nov 2003 09:51:57 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B511216A4CE for ; Sun, 16 Nov 2003 09:51:57 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1886843FDD for ; Sun, 16 Nov 2003 09:51:57 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGHpuXJ001720 for ; Sun, 16 Nov 2003 09:51:56 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGHpugc001717 for perforce@freebsd.org; Sun, 16 Nov 2003 09:51:56 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sun, 16 Nov 2003 09:51:56 -0800 (PST) Message-Id: <200311161751.hAGHpugc001717@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 42558 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 17:51:58 -0000 http://perforce.freebsd.org/chv.cgi?CH=42558 Change 42558 by rwatson@rwatson_tislabs on 2003/11/16 09:51:10 Implement mac_get_peer() in terms of getsockopt(..., SO_PEERLABEL, ...); This provides an API for retrieving socket peer labels that is ABI-neutral concerning the definition of mac_t. Previously, MAC-aware applications had to be able to include sizeof(*mac_t) as an argument to getsockopt(), building binary dependencies into application code that would limit future changes to struct mac. Affected files ... .. //depot/projects/trustedbsd/mac/lib/libc/posix1e/mac.c#14 edit .. //depot/projects/trustedbsd/mac/lib/libc/posix1e/mac_get.c#13 edit .. //depot/projects/trustedbsd/mac/sys/sys/mac.h#254 edit Differences ... ==== //depot/projects/trustedbsd/mac/lib/libc/posix1e/mac.c#14 (text+ko) ==== ==== //depot/projects/trustedbsd/mac/lib/libc/posix1e/mac_get.c#13 (text+ko) ==== @@ -33,6 +33,7 @@ #include #include +#include extern int __mac_get_fd(int fd, struct mac *mac_p); extern int __mac_get_file(const char *path_p, struct mac *mac_p); @@ -61,6 +62,15 @@ return (__mac_get_link(path, label)); } + +int +mac_get_peer(int fd, struct mac *label) +{ + socklen_t len; + + len = sizeof(*label); + return (getsockopt(fd, SOL_SOCKET, SO_PEERLABEL, label, &len)); +} int mac_get_pid(pid_t pid, struct mac *label) { ==== //depot/projects/trustedbsd/mac/sys/sys/mac.h#254 (text+ko) ==== @@ -84,6 +84,7 @@ int mac_get_fd(int _fd, mac_t _label); int mac_get_file(const char *_path, mac_t _label); int mac_get_link(const char *_path, mac_t _label); +int mac_get_peer(int _fd, mac_t _label); int mac_get_pid(pid_t _pid, mac_t _label); int mac_get_proc(mac_t _label); int mac_is_present(const char *_policyname);