diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2025-10-07 09:13:00 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2025-10-07 10:05:08 +0200 |
| commit | a0017a5b5038b3f803ece9140099410c8d4ed4b1 (patch) | |
| tree | 4edacf5e95ebd59392130e60cf57a8bc921554f7 | |
| parent | 3cc24609520e3b4141aed4dec0de9eee64b7bdf6 (diff) | |
cp: fix `cp -aT` overwriting symlink to directories
busybox cp refuses to overwrite another symlink to a directory due to
an incorrect stat() call that should be lstat(). When using -T, we want
to consider the target argument directly without resolving symlinks.
function old new delta
cp_main 496 514 +18
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | coreutils/cp.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/coreutils/cp.c b/coreutils/cp.c index ee40af50b..961de5b42 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c @@ -215,7 +215,8 @@ int cp_main(int argc, char **argv) (flags & FILEUTILS_DEREFERENCE) ? stat : lstat); if (s_flags < 0) /* error other than ENOENT */ return EXIT_FAILURE; - d_flags = cp_mv_stat(last, &dest_stat); + d_flags = cp_mv_stat2(last, &dest_stat, + (flags & FILEUTILS_NO_TARGET_DIR) ? lstat : stat); if (d_flags < 0) /* error other than ENOENT */ return EXIT_FAILURE; |
