Skip to content

Commit 3c8411f

Browse files
committed
feat(in_tail): add configurable permission error handling
1 parent 8dee5dc commit 3c8411f

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

plugins/in_tail/tail.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,14 @@ static struct flb_config_map config_map[] = {
719719
0, FLB_TRUE, offsetof(struct flb_tail_config, skip_empty_lines),
720720
"Allows to skip empty lines."
721721
},
722+
{
723+
FLB_CONFIG_MAP_BOOL, "skip_permission_errors", "false",
724+
0, FLB_TRUE, offsetof(struct flb_tail_config, skip_permission_errors),
725+
"Skip directories with permission errors instead of failing. When enabled, "
726+
"the plugin will continue processing accessible directories even if some directories "
727+
"cannot be read due to permission issues. When disabled (default), any permission error will "
728+
"cause the plugin to fail entirely."
729+
},
722730
#ifdef __linux__
723731
{
724732
FLB_CONFIG_MAP_BOOL, "file_cache_advise", "true",

plugins/in_tail/tail_config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ struct flb_tail_config {
157157
/* List of shell patterns used to exclude certain file names */
158158
struct mk_list *exclude_list;
159159

160+
/* Permission handling configuration */
161+
int skip_permission_errors; /* skip directories with permission errors (1), or fail (0) */
162+
160163
/* Plugin input instance */
161164
struct flb_input_instance *ins;
162165

plugins/in_tail/tail_scan_glob.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,14 @@ static int tail_scan_path(const char *path, struct flb_tail_config *ctx)
203203
/* Safe reset for globfree() */
204204
globbuf.gl_pathv = NULL;
205205

206-
/* Scan the given path */
206+
/* Scan the given path with error checking enabled. */
207207
ret = do_glob(path, GLOB_TILDE | GLOB_ERR, NULL, &globbuf);
208-
if (ret == GLOB_ABORTED) {
208+
if (ret == GLOB_ABORTED && ctx->skip_permission_errors) {
209209
flb_plg_warn(ctx->ins, "read error, check permissions: %s", path);
210210
globfree(&globbuf);
211211
ret = do_glob(path, GLOB_TILDE, NULL, &globbuf);
212212
}
213+
213214
if (ret != 0) {
214215
switch (ret) {
215216
case GLOB_NOSPACE:

0 commit comments

Comments
 (0)