From owner-svn-src-stable-11@freebsd.org Thu Apr 9 16:02:21 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 11B392BE572; Thu, 9 Apr 2020 16:02:21 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48ymB46WNPz3JQS; Thu, 9 Apr 2020 16:02:20 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DADC3F6A7; Thu, 9 Apr 2020 16:02:20 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 039G2Ki6098739; Thu, 9 Apr 2020 16:02:20 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 039G2K9w098737; Thu, 9 Apr 2020 16:02:20 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202004091602.039G2K9w098737@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 9 Apr 2020 16:02:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r359749 - in stable: 11/contrib/openbsm/bin/auditreduce 12/contrib/openbsm/bin/auditreduce X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/contrib/openbsm/bin/auditreduce 12/contrib/openbsm/bin/auditreduce X-SVN-Commit-Revision: 359749 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Apr 2020 16:02:21 -0000 Author: kevans Date: Thu Apr 9 16:02:20 2020 New Revision: 359749 URL: https://svnweb.freebsd.org/changeset/base/359749 Log: MFV r359401: OpenBSM: import ee79d73e8df5: auditreduce: add a zone filter This allows one to select audit records that match a -z zone glob. Modified: stable/11/contrib/openbsm/bin/auditreduce/auditreduce.1 stable/11/contrib/openbsm/bin/auditreduce/auditreduce.c stable/11/contrib/openbsm/bin/auditreduce/auditreduce.h Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/contrib/openbsm/bin/auditreduce/auditreduce.1 stable/12/contrib/openbsm/bin/auditreduce/auditreduce.c stable/12/contrib/openbsm/bin/auditreduce/auditreduce.h Directory Properties: stable/12/ (props changed) Modified: stable/11/contrib/openbsm/bin/auditreduce/auditreduce.1 ============================================================================== --- stable/11/contrib/openbsm/bin/auditreduce/auditreduce.1 Thu Apr 9 15:58:06 2020 (r359748) +++ stable/11/contrib/openbsm/bin/auditreduce/auditreduce.1 Thu Apr 9 16:02:20 2020 (r359749) @@ -25,7 +25,7 @@ .\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd January 24, 2004 +.Dd February 20, 2020 .Dt AUDITREDUCE 1 .Os .Sh NAME @@ -47,6 +47,7 @@ .Op Fl r Ar ruid .Op Fl u Ar auid .Op Fl v +.Op Fl z Ar zone .Op Ar .Sh DESCRIPTION The @@ -129,6 +130,10 @@ Select records with the given real user ID or name. Select records with the given audit ID. .It Fl v Invert sense of matching, to select records that do not match. +.It Fl z Ar zone +Select records from the given zone(s). +.Ar zone +is a glob for zones to match. .El .Sh EXAMPLES To select all records associated with effective user ID root from the audit Modified: stable/11/contrib/openbsm/bin/auditreduce/auditreduce.c ============================================================================== --- stable/11/contrib/openbsm/bin/auditreduce/auditreduce.c Thu Apr 9 15:58:06 2020 (r359748) +++ stable/11/contrib/openbsm/bin/auditreduce/auditreduce.c Thu Apr 9 16:02:20 2020 (r359749) @@ -51,6 +51,7 @@ #include #include +#include #include #include #include @@ -83,6 +84,7 @@ static int p_egid; /* Effective group id. */ static int p_rgid; /* Real group id. */ static int p_ruid; /* Real user id. */ static int p_subid; /* Subject id. */ +static const char *p_zone; /* Zone. */ /* * Maintain a dynamically sized array of events for -m @@ -103,6 +105,8 @@ static char *p_sockobj = NULL; static uint32_t opttochk = 0; +static int select_zone(const char *zone, uint32_t *optchkd); + static void parse_regexp(char *re_string) { @@ -175,6 +179,7 @@ usage(const char *msg) fprintf(stderr, "\t-r : real user\n"); fprintf(stderr, "\t-u : audit user\n"); fprintf(stderr, "\t-v : select non-matching records\n"); + fprintf(stderr, "\t-z : zone name\n"); exit(EX_USAGE); } @@ -482,6 +487,21 @@ select_subj32(tokenstr_t tok, uint32_t *optchkd) } /* + * Check if the given zone matches the selection criteria. + */ +static int +select_zone(const char *zone, uint32_t *optchkd) +{ + + SETOPT((*optchkd), OPT_z); + if (ISOPTSET(opttochk, OPT_z) && p_zone != NULL) { + if (fnmatch(p_zone, zone, FNM_PATHNAME) != 0) + return (0); + } + return (1); +} + +/* * Read each record from the audit trail. Check if it is selected after * passing through each of the options */ @@ -548,6 +568,10 @@ select_records(FILE *fp) tok_hdr32_copy, &optchkd); break; + case AUT_ZONENAME: + selected = select_zone(tok.tt.zonename.zonename, &optchkd); + break; + default: break; } @@ -614,7 +638,7 @@ main(int argc, char **argv) converr = NULL; - while ((ch = getopt(argc, argv, "Aa:b:c:d:e:f:g:j:m:o:r:u:v")) != -1) { + while ((ch = getopt(argc, argv, "Aa:b:c:d:e:f:g:j:m:o:r:u:vz:")) != -1) { switch(ch) { case 'A': SETOPT(opttochk, OPT_A); @@ -766,6 +790,11 @@ main(int argc, char **argv) case 'v': SETOPT(opttochk, OPT_v); + break; + + case 'z': + p_zone = optarg; + SETOPT(opttochk, OPT_z); break; case '?': Modified: stable/11/contrib/openbsm/bin/auditreduce/auditreduce.h ============================================================================== --- stable/11/contrib/openbsm/bin/auditreduce/auditreduce.h Thu Apr 9 15:58:06 2020 (r359748) +++ stable/11/contrib/openbsm/bin/auditreduce/auditreduce.h Thu Apr 9 16:02:20 2020 (r359749) @@ -57,6 +57,7 @@ struct re_entry { #define OPT_u 0x00010000 #define OPT_A 0x00020000 #define OPT_v 0x00040000 +#define OPT_z 0x00080000 #define FILEOBJ "file" #define MSGQIDOBJ "msgqid"