]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
build: update gnulib submodule to latest
authorPádraig Brady <P@draigBrady.com>
Thu, 7 Apr 2022 16:19:37 +0000 (17:19 +0100)
committerPádraig Brady <P@draigBrady.com>
Thu, 7 Apr 2022 16:38:17 +0000 (17:38 +0100)
* gnulib: Update to latest
* src/copy.c: Replace deprecated {l,}statat(), with fstatat().
* src/cp.c: Likewise.
* src/install.c: Likewise.
* src/remove.c: Likewise.

gnulib
src/copy.c
src/cp.c
src/install.c
src/remove.c

diff --git a/gnulib b/gnulib
index a2735049fd84b3ec0cae33c020459995cc7e678f..58c597d13bc57dce3e97ea97856573f2d68ccb8c 160000 (submodule)
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit a2735049fd84b3ec0cae33c020459995cc7e678f
+Subproject commit 58c597d13bc57dce3e97ea97856573f2d68ccb8c
index b8c367c963b145133b4886b677ab1ac49d58b30d..cb31067cda701cac9aae7123f2c8e2ec74027239 100644 (file)
@@ -1535,7 +1535,8 @@ same_file_ok (char const *src_name, struct stat const *src_sb,
       if (!same)
         return true;
 
-      if (lstatat (dst_dirfd, dst_relname, &tmp_dst_sb) != 0
+      if (fstatat (dst_dirfd, dst_relname, &tmp_dst_sb,
+                   AT_SYMLINK_NOFOLLOW) != 0
           || lstat (src_name, &tmp_src_sb) != 0)
         return true;
 
@@ -1688,7 +1689,7 @@ same_file_ok (char const *src_name, struct stat const *src_sb,
 
       if ( ! S_ISLNK (dst_sb_link->st_mode))
         tmp_dst_sb = *dst_sb_link;
-      else if (statat (dst_dirfd, dst_relname, &tmp_dst_sb) != 0)
+      else if (fstatat (dst_dirfd, dst_relname, &tmp_dst_sb, 0) != 0)
         return true;
 
       if ( ! SAME_INODE (tmp_src_sb, tmp_dst_sb))
@@ -1907,7 +1908,7 @@ source_is_dst_backup (char const *srcbase, struct stat const *src_st,
                                  dst_relname + strlen (dst_relname),
                                  simple_backup_suffix);
   struct stat dst_back_sb;
-  int dst_back_status = statat (dst_dirfd, dst_back, &dst_back_sb);
+  int dst_back_status = fstatat (dst_dirfd, dst_back, &dst_back_sb, 0);
   free (dst_back);
   return dst_back_status == 0 && SAME_INODE (*src_st, dst_back_sb);
 }
@@ -2312,12 +2313,13 @@ copy_internal (char const *src_name, char const *dst_name,
       struct stat *dst_lstat_sb;
 
       /* If we did not follow symlinks above, good: use that data.
-         Otherwise, call lstatat here, in case dst_name is a symlink.  */
+         Otherwise, use AT_SYMLINK_NOFOLLOW, in case dst_name is a symlink.  */
       if (have_dst_lstat)
         dst_lstat_sb = &dst_sb;
       else
         {
-          if (lstatat (dst_dirfd, dst_relname, &tmp_buf) == 0)
+          if (fstatat (dst_dirfd, dst_relname, &tmp_buf,
+                       AT_SYMLINK_NOFOLLOW) == 0)
             dst_lstat_sb = &tmp_buf;
           else
             lstat_ok = false;
@@ -2650,7 +2652,8 @@ copy_internal (char const *src_name, char const *dst_name,
              for writing the directory's contents. Check if these
              permissions are there.  */
 
-          if (lstatat (dst_dirfd, dst_relname, &dst_sb) != 0)
+          if (fstatat (dst_dirfd, dst_relname, &dst_sb,
+                       AT_SYMLINK_NOFOLLOW) != 0)
             {
               error (0, errno, _("cannot stat %s"), quoteaf (dst_name));
               goto un_backup;
@@ -2739,8 +2742,8 @@ copy_internal (char const *src_name, char const *dst_name,
                                the failure and say dst_name is in the current
                                directory.  Other things will fail later.  */
                             || stat (".", &dot_sb) != 0
-                            || (statat (dst_dirfd, dst_parent, &dst_parent_sb)
-                                != 0)
+                            || (fstatat (dst_dirfd, dst_parent, &dst_parent_sb,
+                                         0) != 0)
                             || SAME_INODE (dot_sb, dst_parent_sb));
           free (dst_parent);
 
@@ -2916,7 +2919,7 @@ copy_internal (char const *src_name, char const *dst_name,
       /* Now that the destination file is very likely to exist,
          add its info to the set.  */
       struct stat sb;
-      if (lstatat (dst_dirfd, dst_relname, &sb) == 0)
+      if (fstatat (dst_dirfd, dst_relname, &sb, AT_SYMLINK_NOFOLLOW) == 0)
         record_file (x->dest_info, dst_relname, &sb);
     }
 
@@ -3016,7 +3019,8 @@ copy_internal (char const *src_name, char const *dst_name,
                  the lstat, but deducing the current destination mode
                  is tricky in the presence of implementation-defined
                  rules for special mode bits.  */
-              if (new_dst && lstatat (dst_dirfd, dst_relname, &dst_sb) != 0)
+              if (new_dst && fstatat (dst_dirfd, dst_relname, &dst_sb,
+                                     AT_SYMLINK_NOFOLLOW) != 0)
                 {
                   error (0, errno, _("cannot stat %s"), quoteaf (dst_name));
                   return false;
index b73f2cb491442969e75e3c38c55dc8c17d66711b..b2a20b9004b6b79b64bba0378ca38d757e17cdcb 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -391,7 +391,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
 
   /* XXX: If all dirs are present at the destination,
      no permissions or security contexts will be updated.  */
-  if (statat (dst_dirfd, dst_reldir, &stats) != 0)
+  if (fstatat (dst_dirfd, dst_reldir, &stats, 0) != 0)
     {
       /* A parent of CONST_DIR does not exist.
          Make all missing intermediate directories. */
@@ -408,7 +408,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
           bool missing_dir;
 
           *slash = '\0';
-          missing_dir = statat (dst_dirfd, dst_reldir, &stats) != 0;
+          missing_dir = fstatat (dst_dirfd, dst_reldir, &stats, 0) != 0;
 
           if (missing_dir || x->preserve_ownership || x->preserve_mode
               || x->preserve_timestamps)
@@ -488,7 +488,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
                  for writing the directory's contents. Check if these
                  permissions are there.  */
 
-              if (lstatat (dst_dirfd, dst_reldir, &stats))
+              if (fstatat (dst_dirfd, dst_reldir, &stats, AT_SYMLINK_NOFOLLOW))
                 {
                   error (0, errno, _("failed to get attributes of %s"),
                          quoteaf (dir));
index 38e26a887865c5a45f74c1be7974a7fe005c3af7..57a877f4a8a6a2d6e9596a0cf45c355832d4b07d 100644 (file)
@@ -179,7 +179,7 @@ need_copy (char const *src_name, char const *dest_name,
   if (lstat (src_name, &src_sb) != 0)
     return true;
 
-  if (lstatat (dest_dirfd, dest_relname, &dest_sb) != 0)
+  if (fstatat (dest_dirfd, dest_relname, &dest_sb, AT_SYMLINK_NOFOLLOW) != 0)
     return true;
 
   if (!S_ISREG (src_sb.st_mode) || !S_ISREG (dest_sb.st_mode)
index 28d55ff92d0a708005014b50dad9023ece47df86..b5d1ea8a2f53b8ef2f20e15cfecb47d488067ba8 100644 (file)
@@ -385,8 +385,9 @@ excise (FTS *fts, FTSENT *ent, struct rm_options const *x, bool is_dir)
   if (errno == EROFS)
     {
       struct stat st;
-      if ( ! (lstatat (fts->fts_cwd_fd, ent->fts_accpath, &st)
-                       && errno == ENOENT))
+      if ( ! (fstatat (fts->fts_cwd_fd, ent->fts_accpath, &st,
+                       AT_SYMLINK_NOFOLLOW)
+              && errno == ENOENT))
         errno = EROFS;
     }