Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed directory determination #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions input_elements/filesystem-walker.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,24 @@ int open_directory_recursive(const unsigned char *path, void *audit_log_entry_cb
full_path_len = snprintf(full_path, full_path_len + 1, "%s/%s", path,
d_name);

int is_dir = 0;
#ifdef _DIRENT_HAVE_D_TYPE
if (entry->d_type != DT_UNKNOWN && entry->d_type != DT_LNK) {
is_dir = (entry->d_type == DT_DIR);
} else
#endif
{
struct stat stbuf;
if (stat(full_path, &stbuf) != 0) {
e("Failed to determine type for: %s\n", full_path);
res = -1;
goto failed;
}
is_dir = S_ISDIR(stbuf.st_mode);
}

/* if it is a dir (different from "." or ".." we want to jump in. */
if (entry->d_type & DT_DIR)
if (is_dir)
{
if (strcmp (d_name, "..") != 0 && strcmp (d_name, ".") != 0)
{
Expand All @@ -133,7 +149,7 @@ int open_directory_recursive(const unsigned char *path, void *audit_log_entry_cb
}

/* if it is a file, let see inside. */
if (!(entry->d_type & DT_DIR))
if (!is_dir)
{
inspect_file(full_path, audit_log_entry_cb, conf);
}
Expand Down