|
|
d54235 |
From b98dd1933b1ebf5c86041bf135af421fe1ce4fc9 Mon Sep 17 00:00:00 2001
|
|
|
d54235 |
From: Kamil Dudka <kdudka@redhat.com>
|
|
|
d54235 |
Date: Fri, 28 Jun 2019 18:22:39 +0200
|
|
|
d54235 |
Subject: [PATCH] globerr: do not abort globbing on broken symlink
|
|
|
d54235 |
|
|
|
d54235 |
Fixes #251
|
|
|
d54235 |
|
|
|
d54235 |
Upstream-commit: 4297f01103915f4ee356d37bdb35e8c41bbbdb28
|
|
|
d54235 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
d54235 |
---
|
|
|
d54235 |
config.c | 16 +++++++++++++---
|
|
|
d54235 |
test/Makefile.am | 1 +
|
|
|
d54235 |
test/test-0084.sh | 14 ++++++++++++++
|
|
|
d54235 |
test/test-config.84.in | 3 +++
|
|
|
d54235 |
4 files changed, 31 insertions(+), 3 deletions(-)
|
|
|
d54235 |
create mode 100755 test/test-0084.sh
|
|
|
d54235 |
create mode 100644 test/test-config.84.in
|
|
|
d54235 |
|
|
|
d54235 |
diff --git a/config.c b/config.c
|
|
|
d54235 |
index e4807c9..1805a16 100644
|
|
|
d54235 |
--- a/config.c
|
|
|
d54235 |
+++ b/config.c
|
|
|
d54235 |
@@ -834,9 +834,19 @@ static int globerr(const char *pathname, int theerr)
|
|
|
d54235 |
{
|
|
|
d54235 |
(void) pathname;
|
|
|
d54235 |
|
|
|
d54235 |
- /* A missing directory is not an error, so return 0 */
|
|
|
d54235 |
- if (theerr == ENOTDIR)
|
|
|
d54235 |
- return 0;
|
|
|
d54235 |
+ /* prevent glob() from being aborted in certain cases */
|
|
|
d54235 |
+ switch (theerr) {
|
|
|
d54235 |
+ case ENOTDIR:
|
|
|
d54235 |
+ /* non-directory where directory was expected by the glob */
|
|
|
d54235 |
+ return 0;
|
|
|
d54235 |
+
|
|
|
d54235 |
+ case ENOENT:
|
|
|
d54235 |
+ /* most likely symlink with non-existent target */
|
|
|
d54235 |
+ return 0;
|
|
|
d54235 |
+
|
|
|
d54235 |
+ default:
|
|
|
d54235 |
+ break;
|
|
|
d54235 |
+ }
|
|
|
d54235 |
|
|
|
d54235 |
glob_errno = theerr;
|
|
|
d54235 |
|
|
|
d54235 |
diff --git a/test/Makefile.am b/test/Makefile.am
|
|
|
d54235 |
index 5e838d1..35ba2b9 100644
|
|
|
d54235 |
--- a/test/Makefile.am
|
|
|
d54235 |
+++ b/test/Makefile.am
|
|
|
d54235 |
@@ -76,6 +76,7 @@ TEST_CASES = \
|
|
|
d54235 |
test-0075.sh \
|
|
|
d54235 |
test-0076.sh \
|
|
|
d54235 |
test-0077.sh \
|
|
|
d54235 |
+ test-0084.sh \
|
|
|
d54235 |
test-0100.sh \
|
|
|
d54235 |
test-0101.sh
|
|
|
d54235 |
|
|
|
d54235 |
diff --git a/test/test-0084.sh b/test/test-0084.sh
|
|
|
d54235 |
new file mode 100755
|
|
|
d54235 |
index 0000000..1389331
|
|
|
d54235 |
--- /dev/null
|
|
|
d54235 |
+++ b/test/test-0084.sh
|
|
|
d54235 |
@@ -0,0 +1,14 @@
|
|
|
d54235 |
+#!/bin/bash
|
|
|
d54235 |
+
|
|
|
d54235 |
+. ./test-common.sh
|
|
|
d54235 |
+
|
|
|
d54235 |
+cleanup 84
|
|
|
d54235 |
+
|
|
|
d54235 |
+# ------------------------------- Test 84 ------------------------------------
|
|
|
d54235 |
+preptest test.log 84 1
|
|
|
d54235 |
+
|
|
|
d54235 |
+mkdir -p log/dir
|
|
|
d54235 |
+ln -s XXX log/sym
|
|
|
d54235 |
+touch log/dir/file
|
|
|
d54235 |
+
|
|
|
d54235 |
+$RLR test-config.84 -v --force
|
|
|
d54235 |
diff --git a/test/test-config.84.in b/test/test-config.84.in
|
|
|
d54235 |
new file mode 100644
|
|
|
d54235 |
index 0000000..1a79bfe
|
|
|
d54235 |
--- /dev/null
|
|
|
d54235 |
+++ b/test/test-config.84.in
|
|
|
d54235 |
@@ -0,0 +1,3 @@
|
|
|
d54235 |
+&DIR&/log/*/* {
|
|
|
d54235 |
+ rotate 1
|
|
|
d54235 |
+}
|
|
|
d54235 |
--
|
|
|
d54235 |
2.21.3
|
|
|
d54235 |
|