Page MenuHomeFreeBSD

Separate the tests for auditon(2) based on individual commands
ClosedPublic

Authored by aniketp on Jul 13 2018, 1:36 PM.

Details

Summary

This revision introduces tests for auditon(2) based on indivual cmd arguments
as they are categorized as separate audit events

The commands for which tests are introduced in this diff are:

  • A_SETPOLICY
  • A_GETPOLICY
  • A_SETKMASK
  • A_GETKMASK
  • A_SETQCTRL
  • A_GETQCTRL
  • A_SETCOND
  • A_GETCOND
  • A_SETCLASS
  • A_GETCLASS

Please NOTE: auditon(2) has more such events. I'll collect them and add their tests in the next batch.

Test Plan

Execute make && make install from test/sys/audit.
Execute kyua test from /usr/tests/sys/audit. All testcases should succeed.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

aniketp created this revision.Jul 13 2018, 1:36 PM
aniketp edited the summary of this revision. (Show Details)Jul 13 2018, 1:37 PM
asomers requested changes to this revision.Jul 13 2018, 2:34 PM
asomers added inline comments.
tests/sys/audit/administrative.c
752 ↗(On Diff #45242)

Why are you using malloc for a single int? Better to put it on the stack.

805 ↗(On Diff #45242)

As we discussed in your other review, the argument to sizeof is wrong here.

This revision now requires changes to proceed.Jul 13 2018, 2:34 PM
aniketp updated this revision to Diff 45279.Jul 14 2018, 11:38 AM

Store auditinfo in stack instead of allocating heap memory

asomers added inline comments.Jul 14 2018, 3:01 PM
tests/sys/audit/administrative.c
800 ↗(On Diff #45279)

You missed a few mallocs.

aniketp updated this revision to Diff 45289.Jul 14 2018, 4:59 PM
  • Same change as above for the missed mallocs
asomers requested changes to this revision.Jul 15 2018, 8:53 PM

administrative:auditon_setcond_success fails for me every time, probably because you haven't yet fixed the problem with unbuffered I/O in au_read_rec. How's that coming?

This revision now requires changes to proceed.Jul 15 2018, 8:53 PM
asomers added inline comments.Jul 15 2018, 9:02 PM
tests/sys/audit/administrative.c
800 ↗(On Diff #45289)

If you change this into a uint64_t, then it will function as a regression test for the bug you found in A_SETPOLICY.

asomers accepted this revision.Jul 20 2018, 5:34 PM
This revision is now accepted and ready to land.Jul 20 2018, 5:34 PM
asomers requested changes to this revision.Jul 20 2018, 5:46 PM

auditon_setcond_success still fails everytime, and this is why: you pair A_GETCOND with A_SETCOND, but put setup() in the middle. If auditd isn't already running, then setup starts it. However, if auditd wasn't already running, then A_GETCOND will return AUC_DISABLED, and you set that value with auditon. So you should either move A_GETCOND to be after setup, or stop pairing A_GETCOND with A_SETCOND.

This revision now requires changes to proceed.Jul 20 2018, 5:46 PM
aniketp updated this revision to Diff 45623.Jul 20 2018, 6:05 PM
  • Fix the above described bug in auditon_setcond_success
aniketp updated this revision to Diff 45624.Jul 20 2018, 6:10 PM
  • Comment describing the latest change in auditon_setcond_success
asomers accepted this revision.Jul 20 2018, 6:57 PM
This revision is now accepted and ready to land.Jul 20 2018, 6:57 PM
This revision was automatically updated to reflect the committed changes.