Fix the dir module.

Internally, Dir kept track of the files in directory
by storing all inode numbers in a set. However, when a file
is deleted and a new file is created in a directory, the old
file may get the same inode number as the old one. In this
case, bro did not notice the new file.

The patch simply changes the indexing of files - now files
are indexed by inode and creation time.

This should fix the scripts.base.utils.dir test failures.
This commit is contained in:
Bernhard Amann 2013-10-25 18:01:46 -07:00
parent c299a71b83
commit 4b0ee2e7ca

View file

@ -28,7 +28,8 @@ event Dir::monitor_ev(dir: string, last_files: set[string],
callback: function(fname: string),
poll_interval: interval)
{
when ( local result = Exec::run([$cmd=fmt("ls -i -1 \"%s/\"", str_shell_escape(dir))]) )
# the command lists all file in the directory in the form [inode]-[ctime] [filename]
when ( local result = Exec::run([$cmd=fmt("find \"%s\" -depth 1 -exec stat -f \"%%i-%%c %%N\" {} \\;", str_shell_escape(dir))]) )
{
if ( result$exit_code != 0 )
{