IBM Support

AIX AUDIT: How to rotate the audit BIN trail file

How To


Summary

A customized method to rotate audit BIN trail data.

Objective

The AIX audit BIN mode alternates between two binary files defined in the /etc/security/audit/config file.  When one BIN file is full, audit switches to the other BIN file, and adds the accumulated data from the first BIN to the audit TRAIL file. This file might grow to a very large size, so many administrators want to backup, rotate and even compress the TRAIL file. This example provides a method to achieve these goals.

Steps

The AIX Security Expert provides a cron script that rotates the binary audit trail for AIXpert.
You can create a copy of /etc/security/aixpert/bin/cronaudit, then modify it to meet your space and rotation requirements.
1) The following syntax copies the cronaudit file, and adds some variables, so you can customize the script as needed.
           *** NOTE:  Customization is out of the scope of AIX Support
# You can paste the entire content of this box in to a shell script.
# Change these variables as needed. The "fFile" must match the bin: "trail" file value in /etc/security/audit/config.
# Note: By default, the cronaudit script moves the file to a new file name in the same /audit directory. You should consider a different location for best security and space practices. This example moves the file to the /auditBackup file system, and appends a date stamp. Modify this location as needed to meet your requirements.
export CUSTOMFILE=/etc/security/audit/cronaudit.custom
export tFile=/audit/trail
export bFile=/auditBackup/trailOneLevelBack
perl -pe 's/\/audit\/trailOneLevelBack/\$BACKUP/g;s/\/audit\/trail\b/\$TRAIL/g' /etc/security/aixpert/bin/cronaudit | \
perl -pe 's/LOG=\/etc\/security\/aixpert\/log\/aixpert.log/$&\nTRAIL=$ENV{tFile}\nBACKUP=$ENV{bFile}/' | \
perl -pe 's/mv \$TRAIL \$BACKUP/NEWBACKUP=\$BACKUP.`date '+%y%m%d%H%M'`\nmv \$TRAIL \$NEWBACKUP/' > $CUSTOMFILE

 

printf "\n%s was created.\nModify variables as needed, starting at this line:\n" $CUSTOMFILE
grep -ni "LOG="  $CUSTOMFILE
printf "\nAdd compression commands if required, after this line:\n"
grep -ni "mv $TRAIL" $CUSTOMFILE
printf "\nAdd %s as a scheduled cron job.\n" $CUSTOMFILE
# Now update permissions
chmod 500 $CUSTOMFILE
chown root.system  $CUSTOMFILE

 
Example output:
/etc/security/audit/cronaudit.custom was created.
 
Modify variables as needed, starting at this line:
49:LOG=/etc/security/aixpert/log/aixpert.log
Add compression commands if required, after this line:
113:            mv $TRAIL $BACKUP
Add /etc/security/audit/cronaudit.custom as a scheduled cron job.
 
2) You can add a compression command after line 112, per the script output. You can install gzip from the AIX Toolbox for Open Source Software, or you can use the native AIX compress command.
In this example, $CUSTOMFILE=/etc/security/audit/cronaudit.custom
# vi /etc/security/audit/cronaudit.custom
# Add a gzip command
if [ $freespace -lt $cutoff ]
then
audit off

113:mv $TRAIL $NEWBACKUP
 
# Add the gzip command (see the next line)
/opt/freeware/bin/gzip  $NEWBACKUP
audit on
fi
exit 0
OR use AIX native 'compress':
if [ $freespace -lt $cutoff ]
then
audit off
113:mv $TRAIL $NEWBACKUP
# Add the compress command (see the next line)
if compress -c $NEWBACKUP > $NEWBACKUP.Z
then
    rm $NEWBACKUP
else
echo  "Could not compress!"
fi

audit on
fi
exit 0
3) You can add the cronaudit.custom as a cron job.
root@hostname: # crontab -e
0 * * * * /etc/security/audit/cronaudit.custom

Additional Information

SUPPORT

Security configuration involves comprehensive features. Most of these features require advanced review and planning by administrators who are familiar with all of their system requirements. AIX Support does not make specific recommendations to harden your system. Customization is out of the scope of AIX Support, but if you have specific questions about documented usage, our support experts are happy to assist.

You can learn more about the audit functionality on AIX and best practices through the following resources:
 

If you have specific questions about usage after reviewing the recommended documentation, IBM AIX Support will be happy to assist.

If you require consulting services, there are more fee-based services available.

If you require usage assistance, use the following step-by-step instructions to contact IBM to open a case for software with an active and valid support contract.  
 

1.  Document (or collect screen captures of) all symptoms, errors, and messages related to your issue.

2.  Capture any logs or data relevant to the situation.

3.  Contact IBM to open a case:

   -For electronic support, see the IBM Support Community:
     https://www.ibm.com/mysupport
   -If you require telephone support, see the web page:
      https://www.ibm.com/planetwide/

4.  Provide a clear, concise description of the issue.

 

5.  If the system is accessible, collect a system snap, and upload all of the details and data for your case.

  - For guidance, see: Working with IBM AIX Support: Collecting snap data

[{"Type":"MASTER","Line of Business":{"code":"LOB08","label":"Cognitive Systems"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG10","label":"AIX"},"ARM Category":[{"code":"a8m0z000000cw2BAAQ","label":"Security-\u003EAudit"}],"ARM Case Number":"","Platform":[{"code":"PF002","label":"AIX"}],"Version":"All Versions"}]

Document Information

Modified date:
24 May 2024

UID

ibm16825065