From owner-p4-projects@FreeBSD.ORG Tue May 5 01:40:38 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8DE061065672; Tue, 5 May 2009 01:40:38 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4E2BB106566B for ; Tue, 5 May 2009 01:40:38 +0000 (UTC) (envelope-from sson@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 3CE568FC16 for ; Tue, 5 May 2009 01:40:38 +0000 (UTC) (envelope-from sson@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n451ecXY061562 for ; Tue, 5 May 2009 01:40:38 GMT (envelope-from sson@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n451ecQo061560 for perforce@freebsd.org; Tue, 5 May 2009 01:40:38 GMT (envelope-from sson@FreeBSD.org) Date: Tue, 5 May 2009 01:40:38 GMT Message-Id: <200905050140.n451ecQo061560@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sson@FreeBSD.org using -f From: Stacey Son To: Perforce Change Reviews Cc: Subject: PERFORCE change 161590 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 May 2009 01:40:39 -0000 http://perforce.freebsd.org/chv.cgi?CH=161590 Change 161590 by sson@sson_amd64 on 2009/05/05 01:40:11 Add IPv6 support for au_to_me(). Fixes a bug when the terminal ID has an IPv6 address type. au_to_me() now calls getaudit_addr(2) first. If it fails with ENOSYS it falls back to calling getaudit(2) to support legacy systems. Affected files ... .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#92 edit Differences ... ==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#92 (text+ko) ==== @@ -30,7 +30,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#91 $ + * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#92 $ */ #include @@ -1270,12 +1270,27 @@ au_to_me(void) { auditinfo_t auinfo; + auditinfo_addr_t aia; - if (getaudit(&auinfo) != 0) - return (NULL); + /* + * Try to use getaudit_addr(2) first. If this kernel does not support + * it, then fall back on to getaudit(2). + */ + if (getaudit_addr(&aia, sizeof(aia)) != 0) { + if (errno == ENOSYS) { + if (getaudit(&auinfo) != 0) + return (NULL); + return (au_to_subject32(auinfo.ai_auid, geteuid(), + getegid(), getuid(), getgid(), getpid(), + auinfo.ai_asid, &auinfo.ai_termid)); + } else { + /* getaudit_addr(2) failed for some other reason. */ + return (NULL); + } + } - return (au_to_subject32(auinfo.ai_auid, geteuid(), getegid(), - getuid(), getgid(), getpid(), auinfo.ai_asid, &auinfo.ai_termid)); + return (au_to_subject32_ex(aia.ai_auid, geteuid(), getegid(), getuid(), + getgid(), getpid(), aia.ai_asid, &aia.ai_termid)); } #endif