From 4b0ee2e7ca904d150a687435c2e1b0fdbc241572 Mon Sep 17 00:00:00 2001 From: Bernhard Amann Date: Fri, 25 Oct 2013 18:01:46 -0700 Subject: [PATCH] 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. --- scripts/base/utils/dir.bro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/base/utils/dir.bro b/scripts/base/utils/dir.bro index e64af43b15..30d6fed832 100644 --- a/scripts/base/utils/dir.bro +++ b/scripts/base/utils/dir.bro @@ -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 ) {