From owner-p4-projects@FreeBSD.ORG Sun Apr 15 17:59:09 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B59FE16A402; Sun, 15 Apr 2007 17:59:09 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 29D3916A40D for ; Sun, 15 Apr 2007 17:59:09 +0000 (UTC) (envelope-from csjp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 1940F13C45D for ; Sun, 15 Apr 2007 17:59:09 +0000 (UTC) (envelope-from csjp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l3FHx86J082669 for ; Sun, 15 Apr 2007 17:59:08 GMT (envelope-from csjp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l3FHx8de082666 for perforce@freebsd.org; Sun, 15 Apr 2007 17:59:08 GMT (envelope-from csjp@freebsd.org) Date: Sun, 15 Apr 2007 17:59:08 GMT Message-Id: <200704151759.l3FHx8de082666@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to csjp@freebsd.org using -f From: "Christian S.J. Peron" To: Perforce Change Reviews Cc: Subject: PERFORCE change 118188 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: Sun, 15 Apr 2007 17:59:10 -0000 http://perforce.freebsd.org/chv.cgi?CH=118188 Change 118188 by csjp@csjp_xor on 2007/04/15 17:59:05 Add support for parsing zonename tokens. Affected files ... .. //depot/projects/trustedbsd/openbsm/bsm/audit_record.h#25 edit .. //depot/projects/trustedbsd/openbsm/bsm/libbsm.h#33 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_io.c#46 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#61 edit Differences ... ==== //depot/projects/trustedbsd/openbsm/bsm/audit_record.h#25 (text+ko) ==== @@ -30,7 +30,7 @@ * * @APPLE_BSD_LICENSE_HEADER_END@ * - * $P4: //depot/projects/trustedbsd/openbsm/bsm/audit_record.h#24 $ + * $P4: //depot/projects/trustedbsd/openbsm/bsm/audit_record.h#25 $ */ #ifndef _BSM_AUDIT_RECORD_H_ @@ -85,6 +85,7 @@ /* XXXRW: Additional X11 tokens not defined? */ #define AUT_CMD 0x51 #define AUT_EXIT 0x52 +#define AUT_ZONENAME 0x60 /* XXXRW: OpenBSM AUT_HOST 0x70? */ #define AUT_ARG64 0x71 #define AUT_RETURN64 0x72 @@ -330,6 +331,7 @@ token_t *au_to_text(char *text); token_t *au_to_kevent(struct kevent *kev); token_t *au_to_trailer(int rec_size); +token_t *au_to_zonename(char *zonename); __END_DECLS ==== //depot/projects/trustedbsd/openbsm/bsm/libbsm.h#33 (text+ko) ==== @@ -26,7 +26,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/bsm/libbsm.h#32 $ + * $P4: //depot/projects/trustedbsd/openbsm/bsm/libbsm.h#33 $ */ #ifndef _LIBBSM_H_ @@ -653,6 +653,15 @@ char *text; } au_text_t; +/* + * zonename length 2 bytes + * zonename text N bytes + 1 NULL terminator + */ +typedef struct { + u_int16_t len; + char *zonename; +} au_zonename_t; + typedef struct { u_int32_t ident; u_int16_t filter; @@ -721,6 +730,7 @@ au_kevent_t kevent; au_invalid_t invalid; au_trailer_t trail; + au_zonename_t zonename; } tt; /* The token is one of the above types */ }; ==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_io.c#46 (text+ko) ==== @@ -32,7 +32,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_io.c#45 $ + * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_io.c#46 $ */ #include @@ -3860,6 +3860,36 @@ /* + * size 2 bytes; + * zonename size bytes; + */ + +static int +fetch_zonename_tok(tokenstr_t *tok, char *buf, int len) +{ + int err = 0; + + READ_TOKEN_U_INT16(buf, len, tok->tt.zonename.len, tok->len, err); + if (err) + return (-1); + SET_PTR(buf, len, tok->tt.zonename.zonename, tok->tt.zonename.len, + tok->len, err); + if (err) + return (-1); + return (0); +} + +static void +print_zonename_tok(FILE *fp, tokenstr_t *tok, char *del, char raw, + __unused char sfrm, int xml) +{ + + print_tok_type(fp, tok->id, "zone", raw, xml); + print_delim(fp, del); + print_string(fp, tok->tt.zonename.zonename, tok->tt.zonename.len); +} + +/* * Reads the token beginning at buf into tok. */ int @@ -3991,6 +4021,9 @@ case AUT_DATA: return (fetch_arb_tok(tok, buf, len)); + case AUT_ZONENAME: + return (fetch_zonename_tok(tok, buf, len)); + default: return (fetch_invalid_tok(tok, buf, len)); } @@ -4160,6 +4193,10 @@ print_socketex32_tok(outfp, tok, del, raw, sfrm, AU_PLAIN); return; + case AUT_ZONENAME: + print_zonename_tok(outfp, tok, del, raw, sfrm, AU_PLAIN); + return; + default: print_invalid_tok(outfp, tok, del, raw, sfrm, AU_PLAIN); } ==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#61 (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#60 $ + * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#61 $ */ #include @@ -1220,6 +1220,28 @@ } /* + * token ID 1 byte + * zonename length 2 bytes + * zonename N bytes + 1 terminating NULL byte + */ +token_t * +au_to_zonename(char *zonename) +{ + u_char *dptr = NULL; + u_int16_t textlen; + token_t *t; + + textlen = strlen(zonename); + textlen += 1; + GET_TOKEN_AREA(t, dptr, sizeof(u_char) + sizeof(u_int16_t) + textlen); + ADD_U_CHAR(dptr, AUT_ZONENAME); + ADD_U_INT16(dptr, textlen); + ADD_STRING(dptr, zonename, textlen); + return (t); +} + + +/* * token ID 1 byte * count 4 bytes * text count null-terminated strings