* 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 | 2 +- src/copy.c | 24 ++++++++++++++---------- src/cp.c | 6 +++--- src/install.c | 2 +- src/remove.c | 5 +++-- 5 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/gnulib b/gnulib index a2735049f..58c597d13 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit a2735049fd84b3ec0cae33c020459995cc7e678f +Subproject commit 58c597d13bc57dce3e97ea97856573f2d68ccb8c diff --git a/src/copy.c b/src/copy.c index b8c367c96..cb31067cd 100644 --- a/src/copy.c +++ b/src/copy.c @@ -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; diff --git a/src/cp.c b/src/cp.c index b73f2cb49..b2a20b900 100644 --- 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)); diff --git a/src/install.c b/src/install.c index 38e26a887..57a877f4a 100644 --- a/src/install.c +++ b/src/install.c @@ -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) diff --git a/src/remove.c b/src/remove.c index 28d55ff92..b5d1ea8a2 100644 --- a/src/remove.c +++ b/src/remove.c @@ -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; } -- 2.26.2