From owner-p4-projects@FreeBSD.ORG Sat May 17 14:15:50 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D1F311065677; Sat, 17 May 2008 14:15:49 +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 9439A106564A for ; Sat, 17 May 2008 14:15:49 +0000 (UTC) (envelope-from diego@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 80E7F8FC12 for ; Sat, 17 May 2008 14:15:49 +0000 (UTC) (envelope-from diego@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m4HEFn0n074171 for ; Sat, 17 May 2008 14:15:49 GMT (envelope-from diego@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m4HEFnW2074169 for perforce@freebsd.org; Sat, 17 May 2008 14:15:49 GMT (envelope-from diego@FreeBSD.org) Date: Sat, 17 May 2008 14:15:49 GMT Message-Id: <200805171415.m4HEFnW2074169@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to diego@FreeBSD.org using -f From: Diego Giagio To: Perforce Change Reviews Cc: Subject: PERFORCE change 141767 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: Sat, 17 May 2008 14:15:50 -0000 http://perforce.freebsd.org/chv.cgi?CH=141767 Change 141767 by diego@diego_black on 2008/05/17 14:14:58 - Minimize code duplication - Improve comments Affected files ... .. //depot/projects/soc2008/diego-audit/src/sys/security/audit/audit_pfil.c#4 edit Differences ... ==== //depot/projects/soc2008/diego-audit/src/sys/security/audit/audit_pfil.c#4 (text+ko) ==== @@ -40,42 +40,45 @@ #include #include -static void -audit_enable_common(char *name, int error) +/* + * Create a new audit record. Also add a text token with packet filter's name + * to the record. This function may return NULL. + */ +static struct kaudit_record * +audit_pfil_begin(int event, char *name) { struct kaudit_record *ar; - ar = audit_begin(AUE_PFIL_ENABLE, curthread); + ar = audit_begin(event, curthread /* XXXDG */); if (ar == NULL) - return; + return NULL; audit_record_arg_text(ar, name); - audit_commit(ar, error, 0); + return (ar); } -static void -audit_disable_common(char *name, int error) +void +audit_ipfw_enable(int error) { struct kaudit_record *ar; - ar = audit_begin(AUE_PFIL_DISABLE, curthread); + ar = audit_pfil_begin(AUE_PFIL_ENABLE, "ipfw"); if (ar == NULL) return; - audit_record_arg_text(ar, name); audit_commit(ar, error, 0); } void -audit_ipfw_enable(int error) +audit_ipfw_disable(int error) { - audit_enable_common("ipfw", error); -} + struct kaudit_record *ar; + + ar = audit_pfil_begin(AUE_PFIL_DISABLE, "ipfw"); + if (ar == NULL) + return; -void -audit_ipfw_disable(int error) -{ - audit_disable_common("ipfw", error); + audit_commit(ar, error, 0); } void @@ -83,12 +86,11 @@ { struct kaudit_record *ar; - ar = audit_begin(AUE_PFIL_POLICY_ADDRULE, curthread); + ar = audit_pfil_begin(AUE_PFIL_POLICY_ADDRULE, "ipfw"); if (ar == NULL) return; - audit_record_arg_text(ar, "ipfw"); - /* XXX tokens */ + /* XXXDG: add tokens */ audit_commit(ar, error, 0); } @@ -97,12 +99,11 @@ { struct kaudit_record *ar; - ar = audit_begin(AUE_PFIL_POLICY_DELRULE, curthread); + ar = audit_pfil_begin(AUE_PFIL_POLICY_DELRULE, "ipfw"); if (ar == NULL) return; - audit_record_arg_text(ar, "ipfw"); - /* XXX tokens */ + /* XXXDG: add tokens */ audit_commit(ar, error, 0); } @@ -111,12 +112,11 @@ { struct kaudit_record *ar; - ar = audit_begin(AUE_PFIL_POLICY_FLUSH, curthread); + ar = audit_pfil_begin(AUE_PFIL_POLICY_FLUSH, "ipfw"); if (ar == NULL) return; - audit_record_arg_text(ar, "ipfw"); - /* XXX tokens */ + /* XXXDG: add tokens */ audit_commit(ar, error, 0); } @@ -125,24 +125,35 @@ { struct kaudit_record *ar; - ar = audit_begin(AUE_PFIL_POLICY_TABLE, curthread); + ar = audit_pfil_begin(AUE_PFIL_POLICY_TABLE, "ipfw"); if (ar == NULL) return; - audit_record_arg_text(ar, "ipfw"); - /* XXX tokens */ + /* XXXDG: add tokens */ audit_commit(ar, error, 0); } void audit_pf_enable(int error) { - audit_enable_common("pf", error); + struct kaudit_record *ar; + + ar = audit_pfil_begin(AUE_PFIL_ENABLE, "pf"); + if (ar == NULL) + return; + + audit_commit(ar, error, 0); } void audit_pf_disable(int error) { - audit_disable_common("pf", error); + struct kaudit_record *ar; + + ar = audit_pfil_begin(AUE_PFIL_DISABLE, "pf"); + if (ar == NULL) + return; + + audit_commit(ar, error, 0); }