]> Savannah Git Hosting - gnulib.git/commitdiff
lchmod: Fix link error on Solaris 10 (regression from 2020-02-16).
authorBruno Haible <bruno@clisp.org>
Sat, 22 Feb 2020 23:44:20 +0000 (00:44 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 22 Feb 2020 23:44:20 +0000 (00:44 +0100)
* lib/lchmod.c (lchmod): Use the code with lstat and chmod also when
NEED_LCHMOD_NONSYMLINK_FIX is not defined.

ChangeLog
lib/lchmod.c

index a8a37d9633fe0626af23de69a03f393176cbedbc..71a6ce343986da1d5932d44122bc18a4dfa3755d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-02-22  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        Use 'restrict' in all POSIX function declarations.
index 57f75da8cfa8cb54267afda263e35c02411e2216..e62111cb8b7ca9dc0841f717b32ddadf0b117a82 100644 (file)
@@ -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
 }