Linux-audit Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Grubb <sgrubb@redhat.com>
To: "Gulland, Scott A" <scott.gulland@hpe.com>
Cc: "linux-audit@redhat.com" <linux-audit@redhat.com>
Subject: Re: Use case not covered by the audit library?
Date: Mon, 11 Jan 2016 16:12:12 -0500	[thread overview]
Message-ID: <14106614.VpUO6lg5qc@x2> (raw)
In-Reply-To: <B41870ED03633F4092CDF476119204DF561D5A23@G4W3225.americas.hpqcorp.net>

On Wednesday, January 06, 2016 08:27:31 PM Gulland, Scott A wrote:
> > What I would suggest in a case like this is to create a small utility that
> > generates the exact report that you want. The auparse library makes that
> > super easy. I can dig up the skeleton code for something like this if you
> > want.
>
> Thanks Steve!   I'd appreciate the skeleton code.   At some point we'll
> probably want to create a custom report capability.   It sounds like
> ausearch really only handles the fields written by the kernel.

Sorry for the delay, I needed to get the 2.5 package out the door.

There is some example code in the audit package and here:
https://fedorahosted.org/audit/browser/trunk/contrib/plugin/audisp-example.c

If you wanted to read from a file, then you change the code to 

        f = fopen("./test.log", "r");
        if (f == NULL) {
                printf("Can't open log\n");
                return 1;
        }

but keep the AUSOURCE_FEED. Then in the loop

                /* Now the event loop */
                 if (!stop && !hup && retval > 0) {
                        if (fgets_unlocked(tmp, MAX_AUDIT_MESSAGE_LENGTH, f)) {
                                auparse_feed(au, tmp, strnlen(tmp,
                                                MAX_AUDIT_MESSAGE_LENGTH));
                        }
                } else if (retval == 0)
                        auparse_flush_feed(au);
                if (feof(f))
                        break;

Then you put the report in the callback function. You can switch between the
types as shown in the handle_event function.

If you want it to run off of logs, then you would need to structure things a
bit different. The aulastlog program shows a good example of that:

https://fedorahosted.org/audit/browser/trunk/tools/aulastlog/aulastlog.c

Hope this helps...

-Steve

      reply	other threads:[~2016-01-11 21:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-15  5:13 Use case not covered by the audit library? Gulland, Scott A
2015-12-16 14:22 ` Steve Grubb
2015-12-16 19:55   ` Burn Alting
2015-12-17  4:53     ` Gulland, Scott A
2015-12-17  4:21   ` Gulland, Scott A
2015-12-17  6:10     ` Richard Guy Briggs
2015-12-18  2:51       ` Steve Grubb
2016-01-05 21:59         ` Gulland, Scott A
2016-01-06 16:28           ` Steve Grubb
2016-01-06 18:03             ` Gulland, Scott A
2016-01-06 20:05               ` Steve Grubb
2016-01-06 20:27                 ` Gulland, Scott A
2016-01-11 21:12                   ` Steve Grubb [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14106614.VpUO6lg5qc@x2 \
    --to=sgrubb@redhat.com \
    --cc=linux-audit@redhat.com \
    --cc=scott.gulland@hpe.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox