diff --git a/plugins/in_tail/tail.c b/plugins/in_tail/tail.c index 41ac94a95bc..dfebd596fb2 100644 --- a/plugins/in_tail/tail.c +++ b/plugins/in_tail/tail.c @@ -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", diff --git a/plugins/in_tail/tail_config.h b/plugins/in_tail/tail_config.h index 326dba870a4..20c5d7c7d80 100644 --- a/plugins/in_tail/tail_config.h +++ b/plugins/in_tail/tail_config.h @@ -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; diff --git a/plugins/in_tail/tail_scan_glob.c b/plugins/in_tail/tail_scan_glob.c index 60259880ab3..383d29c3bd0 100644 --- a/plugins/in_tail/tail_scan_glob.c +++ b/plugins/in_tail/tail_scan_glob.c @@ -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: