diff options
| -rw-r--r-- | source/scan-tree.c | 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rwxr-xr-x | tests/t0303-robustness.sh | 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 files changed, 31 insertions, 2 deletions
diff --git a/source/scan-tree.c b/source/scan-tree.c index b941ec5..7e7f28b 100644 --- a/source/scan-tree.c +++ b/source/scan-tree.c @@ -32,7 +32,7 @@ static int stat_entry(const char *dir, const char *name, struct stat *st) // A missing entry is the ordinary answer for a directory that is not a // repository, so only some other failure is worth reporting. if (err && errno != ENOENT) - fprintf(stderr, "[cgit] Unable to stat %s: %s (%d)\n", dir, strerror(errno), errno); + fprintf(stderr, "[cgit] Unable to stat %s: %s (%d)\n", path.buf, strerror(errno), errno); strbuf_release(&path); return err; } @@ -363,7 +363,8 @@ void scan_projects(const char *path, const char *projectsfile) strbuf_insert(&line, 0, path, strlen(path)); scan_path(path, line.buf); } - if ((err = ferror(projects))) { + if (ferror(projects)) { + err = errno; fprintf(stderr, "[cgit] Unable to read project list %s: %s (%d)\n", projectsfile, strerror(err), err); } diff --git a/tests/t0303-robustness.sh b/tests/t0303-robustness.sh index 3f9c80d..87a85ce 100755 --- a/tests/t0303-robustness.sh +++ b/tests/t0303-robustness.sh @@ -655,4 +655,32 @@ test_expect_success 'a chain of single directories is followed a bounded number test $(grep -o "class=.ls-dir." tmp | wc -l) -le 17 ' +# The line has to carry the read error rather than the flag ferror returns. +# Linux opens a directory and fails the read, while macOS already refuses the +# open, so the same error text is expected from either path. +test_expect_success 'an unreadable project list is named with its error' ' + mkdir -p projdir && + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "project-list=$PWD/projdir" && + echo "scan-path=$PWD/repos" + } >projrc && + CGIT_CONFIG="$PWD/projrc" QUERY_STRING="url=" cgit >tmp 2>err && + grep "project list .*projdir: Is a directory" err +' + +test_expect_success SANITY 'a scan entry that cannot be searched is named in full' ' + mkdir -p scanperm/locked && + test_when_finished "chmod 755 scanperm/locked" && + chmod 644 scanperm/locked && + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "scan-path=$PWD/scanperm" + } >scanpermrc && + CGIT_CONFIG="$PWD/scanpermrc" QUERY_STRING="url=" cgit >tmp 2>err && + grep "Unable to stat .*scanperm/locked/objects: Permission denied" err +' + test_done |
