Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 May 2009 01:40:38 GMT
From:      Stacey Son <sson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 161590 for review
Message-ID:  <200905050140.n451ecQo061560@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <sys/types.h>
@@ -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
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905050140.n451ecQo061560>