Skip to content

Commit

Permalink
globerr: do not abort globbing on broken symlink
Browse files Browse the repository at this point in the history
Fixes #251
  • Loading branch information
kdudka committed Jun 28, 2019
1 parent 66921e4 commit 4297f01
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
16 changes: 13 additions & 3 deletions config.c
Expand Up @@ -839,9 +839,19 @@ static int globerr(const char *pathname, int theerr)
{
(void) pathname;

/* A missing directory is not an error, so return 0 */
if (theerr == ENOTDIR)
return 0;
/* prevent glob() from being aborted in certain cases */
switch (theerr) {
case ENOTDIR:
/* non-directory where directory was expected by the glob */
return 0;

case ENOENT:
/* most likely symlink with non-existent target */
return 0;

default:
break;
}

glob_errno = theerr;

Expand Down
1 change: 1 addition & 0 deletions test/Makefile.am
Expand Up @@ -82,6 +82,7 @@ TEST_CASES = \
test-0081.sh \
test-0082.sh \
test-0083.sh \
test-0084.sh \
test-0100.sh \
test-0101.sh

Expand Down
14 changes: 14 additions & 0 deletions test/test-0084.sh
@@ -0,0 +1,14 @@
#!/bin/bash

. ./test-common.sh

cleanup 84

# ------------------------------- Test 84 ------------------------------------
preptest test.log 84 1

mkdir -p log/dir
ln -s XXX log/sym
touch log/dir/file

$RLR test-config.84 -v --force
3 changes: 3 additions & 0 deletions test/test-config.84.in
@@ -0,0 +1,3 @@
&DIR&/log/*/* {
rotate 1
}

0 comments on commit 4297f01

Please sign in to comment.