[INFO] What package, script or process is creating /etc/cron.daily/auditd.cron?
PREFACE (EDIT): Please keep in mind 2 things before posting, as they have been visited several times and are not part of our issue.
1) Before we posted this, we had already done the following RPM commands: -qf (RPM [what]provides), -q --scripts (RPM scripts), -q --triggers (RPM triggers). We are trying to figure out what process is copying the file /usr/share/doc/audit-*/auditd.cron to /etc/cron.daily. It seems to be a post-installation process not in any RPM, file, script or trigger.
2) We are not using logrotate for audit, period. auditd.cron and logrotate are for different sets of files, as part of a greater solution reduce disk usage for logging and auditing. We use logrotate and its inherent (zip -9) compression for those files in logrotate which, again, does not include auditd's logs. We are also using other scripts -- cron.hourly/zlogs.cron (ORIGINAL) and cron.monthly/arclogs.cron (NEW) -- to rename/compress audit and other log files as well as move them to another file system. The latter, normally run monthly, even gets automatically kicked off, per audit/auditd.conf, when the file system drops to under 0.5GiB free.
LONGER INQUIRY (ORIGINAL): We are building an RPM to modify/rotate/compress logs on RHEL 6.
This includes the logrotate and auditd services. We wish to move /etc/cron.daily/logrotate and /etc/cron.daily/auditd.cron to /etc/cron.hourly/, so it rotates hourly. As part of our RPM SPEC, we are going to build a trigger that will re-move these files to /etc/cron.hourly/. in case they are updated in /etc/cron.daily/.
Although the package "logrotate" includes the /etc/cron.daily/logrotate file, the /etc/cron.daily/auditd.cron file is neither part of the package "audit" nor created as part of the scripts of package "audit". Using "rpm -q --whatprovides /etc/cron.daily/auditd.cron" and "rpm -qa --scripts" we are unable to determine how it is created at RPM install-time, or by any RPM/YUM action.
Searching Bugzilla only results in bz#811588 ( https://bugzilla.redhat.com/show_bug.cgi?id=811588 ), which shows this file is coped from /usr/share/doc/audit-*/, but not when this step occurs. Please advise on how this file is created, and how we may handle whenever it could be updated.
Something always creates /etc/cron.daily/auditd.conf, but it is neither a RPM managed file nor created as part of a RPM script, from what we can tell.
UPDATE: After several Kickstart tests and an overnight burn-in, I cannot track down what is copying this file from /usr/share/doc/audit-*/. I believe it may not be a Red Hat installed process, facility or other solution, but a site-specific process.
Responses
A symlink comes comes to mind;
%> ln -s /etc/cron.daily/logrotate /etc/cron.hourly/logrotate
%> ln -s /etc/cron.daily/auditd.cron /etc/cron.hourly/auditd.cron
That will keep your file up to date with changes on new/upgrades of logrotate &/or auditd.
In regards to your log rotation tool, why not just use logrotated and add your custom logs to the syslog facility?
Hi Bryan,
I checked my systems. I (of course) found the same results as you.
Additionally, I checked my systems for the existence of the file at /etc/cron.daily/auditd.cron by pushing a query from my satellite server. None of my systems have the file named "/etc/cron.daily/auditd.cron"
Is there any chance someone is making this file as the result of a different cron, or a script within a cron? Or maybe someone is putting the file there via another means? I have seen where some ... people ... drop in files under /etc/cron.daily for their own needs, in a less-than-documented way.
Is there any chance someone's pushing this file via some other method that's not the function of a script, such as ansible or puppet or some other means?
Hope you find the culprit function that's creating that file... good luck
%> su -c 'yum whatprovides */auditd.cron'
Password:
Loaded plugins: product-id, refresh-packagekit, rhnplugin, security, subscription-manager
This system is receiving updates from RHN Classic or RHN Satellite.
epel/filelists_db | 8.0 MB 00:00
rhel-x86_64-server-6/filelists | 26 MB 00:27
rhel-x86_64-server-optional-6/filelists | 10 MB 00:10
audit-2.1.3-3.el6.x86_64 : User space tools for 2.6 kernel auditing
Repo : rhel-x86_64-server-6
Matched from:
Filename : /usr/share/doc/audit-2.1.3/auditd.cron
audit-2.1-5.el6.x86_64 : User space tools for 2.6 kernel auditing
Repo : rhel-x86_64-server-6
Matched from:
Filename : /usr/share/doc/audit-2.1/auditd.cron
audit-2.0.4-1.el6.x86_64 : User space tools for 2.6 kernel auditing
Repo : rhel-x86_64-server-6
Matched from:
Filename : /usr/share/doc/audit-2.0.4/auditd.cron
audit-2.2-4.el6_5.x86_64 : User space tools for 2.6 kernel auditing
Repo : rhel-x86_64-server-6
Matched from:
Filename : /usr/share/doc/audit-2.2/auditd.cron
audit-2.3.7-5.el6.x86_64 : User space tools for 2.6 kernel auditing
Repo : rhel-x86_64-server-6
Matched from:
Filename : /usr/share/doc/audit-2.3.7/auditd.cron
audit-2.2-2.el6.x86_64 : User space tools for 2.6 kernel auditing
Repo : rhel-x86_64-server-6
Matched from:
Filename : /usr/share/doc/audit-2.2/auditd.cron
audit-2.3.7-5.el6.x86_64 : User space tools for 2.6 kernel auditing
Repo : installed
Matched from:
Filename : /usr/share/doc/audit-2.3.7/auditd.cron
You can monitor processes with this and examine the strace for possible creation of the auditd.conf after removing it.
#!/bin/sh
# Change 'auditd' for whatever pattern you wish to examine
for pid in $(lsof | grep auditd | awk '$1 ~ /^auditd$/ && $9 ~ /^\/[sbin|lib|var].*/{print $2":"$9}'); do
file=$(echo "${pid}"|cut -d : -f 2);
proc=$(echo "${pid}"|cut -d : -f 1);
if [[ "$(file ${file})" =~ object ]]; then
# Schedule the killing of strace
echo "kill -9 $(ps -ef|grep -v grep|grep strace|awk '{print $2}')"|at now + 1 min
# Watch & log the ${proc}
strace -fo /var/tmp/${proc}-$(basename ${file})-strace.log -p ${proc}
fi
done
I figured from the onset that was your goal, to track down the means "/etc/cron.daily/auditd.cron" was appearing on your system. Nice bit you posted with the rpm spec file you made.
I have heard tacit discussion (but have not found anything documented... yet) for /etc/some.conf.override file (ending in "override"). I'm not personally fully versed in the use of that, but I had thought from the tacit info I read, that could retain a configuration file one may want to keep. Have you heard of this or know of any documentation that covers it (I've not found any yet, still searching)? Of course there are instances where this may not be something someone wants.
When I did my "rpm -ql" queries, I did not see "/etc/cron.daily/auditd.cron" as a resultant file from the audit RPM, but the "rpm -ql audit" of course shows "/etc/audit/auditd.conf". I did some queries as I mentioned (tacitly) and found the same results as you.
I just (now) did a kickstart of rhel 7.2 and (of course) I did not see "/etc/cron.daily/auditd.cron" and of course the /etc/audit/auditd.conf was present as listed and expected.
Usually, when trying to track down where files come from I do something like rpm -qf $(readlink -f /path/to/file).
Neither my EL6 nor EL7 systems have an /etc/cron.daily/auditd.cron file. Then again, it's more typical to have the actual auditd service configured to handle its own log-rotation rather than using logrotate/cron. Looking at rpm -qVf $(readlink -f /etc/audit/auditd.conf) (on a test system), its default configuration has auditd handling its own log roatation:
num_logs = 5
max_log_file = 6
max_log_file_action = ROTATE
Generally, it's bad juju if you have both auditd and logrotate trying to rotate the same set of files.
And what I'm saying is that, on the unmodified EL6 and EL7 test systems (AWS is awesome for quickly genning "stock"systems), no auditd.cron scripts get created. The default is to use the functionality built into the auditd service (thus, the posting of the excerpted /etc/auditd/auditd.conf file).
Usually, when I see someone using a cron job, it's because they've specifically disabled auditd's internal log-rotation and then created the cron job via other avenues. Perhaps whoever put together your KickStart (or other standard build) profile opted to incorporate the cron-enabled auditd log-rotation?
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
