From a7f76250e6cbbf24e710a8b1f25c1596c97b02c0 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 23 Feb 2020 00:44:20 +0100 Subject: [PATCH] lchmod: Fix link error on Solaris 10 (regression from 2020-02-16). * lib/lchmod.c (lchmod): Use the code with lstat and chmod also when NEED_LCHMOD_NONSYMLINK_FIX is not defined. --- ChangeLog | 6 ++++++ lib/lchmod.c | 20 +++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index a8a37d9633..71a6ce3439 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2020-02-22 Bruno Haible + + lchmod: Fix link error on Solaris 10 (regression from 2020-02-16). + * lib/lchmod.c (lchmod): Use the code with lstat and chmod also when + NEED_LCHMOD_NONSYMLINK_FIX is not defined. + 2020-02-22 Bruno Haible Use 'restrict' in all POSIX function declarations. diff --git a/lib/lchmod.c b/lib/lchmod.c index 57f75da8cf..e62111cb8b 100644 --- a/lib/lchmod.c +++ b/lib/lchmod.c @@ -64,9 +64,9 @@ lchmod (char const *file, mode_t mode) /* Gnulib's fchmodat contains the workaround. No need to duplicate it here. */ return fchmodat (AT_FDCWD, file, mode, AT_SYMLINK_NOFOLLOW); -#elif NEED_LCHMOD_NONSYMLINK_FIX -# if defined AT_FDCWD && defined O_PATH && defined AT_EMPTY_PATH \ - && (defined __linux__ || defined __ANDROID__) +#elif NEED_LCHMOD_NONSYMLINK_FIX \ + && defined AT_FDCWD && defined O_PATH && defined AT_EMPTY_PATH \ + && (defined __linux__ || defined __ANDROID__) /* newer Linux */ /* Open a file descriptor with O_NOFOLLOW, to make sure we don't follow symbolic links, if /proc is mounted. O_PATH is used to avoid a failure if the file is not readable. @@ -113,8 +113,9 @@ lchmod (char const *file, mode_t mode) /* /proc is not mounted. */ /* Fall back on chmod, despite the race. */ return chmod (file, mode); -# elif HAVE_LSTAT -# if (defined __linux__ || defined __ANDROID__) || !HAVE_LCHMOD +#elif HAVE_LSTAT +# if (NEED_LCHMOD_NONSYMLINK_FIX && (defined __linux__ || defined __ANDROID__)) \ + || !HAVE_LCHMOD /* older Linux, Solaris 10 */ struct stat st; int lstat_result = lstat (file, &st); if (lstat_result != 0) @@ -126,13 +127,10 @@ lchmod (char const *file, mode_t mode) } /* Fall back on chmod, despite the race. */ return chmod (file, mode); -# else /* GNU/kFreeBSD, GNU/Hurd, macOS, FreeBSD, NetBSD, HP-UX */ +# else /* GNU/kFreeBSD, GNU/Hurd, macOS, FreeBSD, NetBSD, HP-UX */ return orig_lchmod (file, mode); -# endif -# else /* native Windows */ - return chmod (file, mode); # endif -#else - return orig_lchmod (file, mode); +#else /* native Windows */ + return chmod (file, mode); #endif } -- 2.39.5