Linux – Using auditd to watch a directory non-recursively

auditdcentosfile-permissionslinux

I'm working on a Cent 6 Cpanel machine, and some mystery script is changing the permissions of home directories (!) to 777. I've ruled out all the easy fixes, so I just need to set up a watch on the directory and wait until it happens again.

The trouble is, my current rule:

`auditctl -w /home -pa -k homedir_perm_changes`

is watching the entire home directory recursively, and this partition stores emails and documentroots, so there's entirely too much information.

How can I pare down my rule such that it watches only the directories directly under /home, and not the entire (huge) directory tree beneath it?

Thanks!

Best Answer

It seems like this option is not implemented yet. Might be a technical limitation as system calls on inodes are watched.

Just an idea: You could work around this limitation with a good grep, for example:

ausearch -i -k yourauditkey | grep "name=/etc/ "

(Note the space after /etc/) It is dirty, but should help you, because it crops all subdirectories out of it.

Related Topic