Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions plugins/in_tail/tail.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,14 @@ static struct flb_config_map config_map[] = {
0, FLB_TRUE, offsetof(struct flb_tail_config, skip_empty_lines),
"Allows to skip empty lines."
},
{
FLB_CONFIG_MAP_BOOL, "skip_permission_errors", "false",
0, FLB_TRUE, offsetof(struct flb_tail_config, skip_permission_errors),
"Skip directories with permission errors instead of failing. When enabled, "
"the plugin will continue processing accessible directories even if some directories "
"cannot be read due to permission issues. When disabled (default), any permission error will "
"cause the plugin to fail entirely."
},
#ifdef __linux__
{
FLB_CONFIG_MAP_BOOL, "file_cache_advise", "true",
Expand Down
3 changes: 3 additions & 0 deletions plugins/in_tail/tail_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ struct flb_tail_config {
/* List of shell patterns used to exclude certain file names */
struct mk_list *exclude_list;

/* Permission handling configuration */
int skip_permission_errors; /* skip directories with permission errors (1), or fail (0) */

/* Plugin input instance */
struct flb_input_instance *ins;

Expand Down
8 changes: 7 additions & 1 deletion plugins/in_tail/tail_scan_glob.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,14 @@ static int tail_scan_path(const char *path, struct flb_tail_config *ctx)
/* Safe reset for globfree() */
globbuf.gl_pathv = NULL;

/* Scan the given path */
/* Scan the given path with error checking enabled. */
ret = do_glob(path, GLOB_TILDE | GLOB_ERR, NULL, &globbuf);
if (ret == GLOB_ABORTED && !ctx->skip_permission_errors) {
flb_plg_warn(ctx->ins, "read error, check permissions: %s", path);
globfree(&globbuf);
ret = do_glob(path, GLOB_TILDE, NULL, &globbuf);
}

if (ret != 0) {
switch (ret) {
case GLOB_NOSPACE:
Expand Down
Loading