From 8d12036047eb6cba16d3ae3f6b43c789d8378462 Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Tue, 10 Feb 2015 22:31:56 +0100 Subject: Fix symlinks test case on some architectures * src/safe.c: Include util.h for say(). Define EFTYPE if it isn't defined already. (traverse_another_path): When openat fails, also check for EMLINK, EFTYPE, and ENOTDIR. Change the error message to "file ... is not a directory" and only skip the rest of the patch instead of aborting. * tests/symlinks: Update. --- src/safe.c | 17 +++++++++++++---- tests/symlinks | 5 +++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/safe.c b/src/safe.c index eec6ce5..9ce722b 100644 --- a/src/safe.c +++ b/src/safe.c @@ -39,6 +39,12 @@ #define XTERN extern #include "common.h" +#include "util.h" + +#ifndef EFTYPE +# define EFTYPE 0 +#endif + /* Path lookup results are cached in a hash table + LRU list. When the cache is full, the oldest entries are removed. */ @@ -278,11 +284,14 @@ static int traverse_another_path (const char **pathname, int keepfd) printf (" (failed)\n"); fflush (stdout); } - if (errno == ELOOP) + if (errno == ELOOP + || errno == EMLINK /* FreeBSD 10.1: Too many links */ + || errno == EFTYPE /* NetBSD 6.1: Inappropriate file type or format */ + || errno == ENOTDIR) { - fprintf (stderr, "Refusing to follow symbolic link %.*s\n", - (int) (path - *pathname), *pathname); - fatal_exit (0); + say ("file %.*s is not a directory\n", + (int) (path - *pathname), *pathname); + skip_rest_of_patch = true; } return dirfd; } diff --git a/tests/symlinks b/tests/symlinks index f93f1cc..4383a49 100644 --- a/tests/symlinks +++ b/tests/symlinks @@ -196,8 +196,9 @@ EOF check 'patch -f -p1 < follow-symlink.diff || echo "Status: $?"' < bad-symlink-target1.diff <