PERFORCE change 118188 for review

Christian S.J. Peron csjp at FreeBSD.org
Sun Apr 15 17:59:10 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=118188

Change 118188 by csjp at 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 <sys/types.h>
@@ -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 <sys/types.h>
@@ -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


More information about the p4-projects mailing list