Skip to content

cp --reflink=auto panics when copying nested symlinks with restrict permissions #2314

@SuperSandro2000

Description

@SuperSandro2000
cp -pr --reflink=auto -- /nix/store/dl6ahdcycmw4yry2zpmslq7w7i2mdlvk-source source
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/uu/cp/src/cp.rs:1257:10
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: uu_cp::copy_helper
   4: uu_cp::copy_file
   5: uu_cp::copy
   6: uu_cp::uumain
   7: coreutils::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
result/bin/uutils-cp -r --reflink=auto /nix/store/dvh1x2m7gvp1iv5jjlvrf5ry5g3ay23k-source source
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }', src/uu/cp/src/cp.rs:1257:10
stack backtrace:
   0:     0x626c2f3f510c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h579b28686b409bee
   1:     0x626c2f41f10f - core::fmt::write::h177edd21b8369127
   2:     0x626c2f3f4666 - std::io::Write::write_fmt::haa2ae72671ba5de2
   3:     0x626c2f3d4a85 - std::panicking::default_hook::{{closure}}::h71a46c54ea32ce02
   4:     0x626c2f3d4653 - std::panicking::default_hook::h562e9028aa910d56
   5:     0x626c2f3d50ea - std::panicking::rust_panic_with_hook::hb6c7abba650d43fa
   6:     0x626c2f3f5597 - std::panicking::begin_panic_handler::{{closure}}::h477cfd41c4af51c1
   7:     0x626c2f3f524c - std::sys_common::backtrace::__rust_end_short_backtrace::h2441af18d2e25caa
   8:     0x626c2f3d4c62 - rust_begin_unwind
   9:     0x626c2f422381 - core::panicking::panic_fmt::h517c1ed6f8518cd6
  10:     0x626c2f427953 - core::result::unwrap_failed::h441cbb6e6d50fbfd
  11:     0x626c2f32a62e - uu_cp::copy_helper::h0d6f49dd6ece054a
  12:     0x626c2f327b35 - uu_cp::copy_file::h61df3196d7a7b976
  13:     0x626c2f325c32 - uu_cp::copy::h8f71f7611c902b71
  14:     0x626c2f01006a - uu_cp::uumain::h95ac159c93136cc4
  15:     0x626c2efe15e0 - coreutils::main::h034f826d5af37e42
  16:     0x626c2efdc2d3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h612ef4d5ed08f219
  17:     0x626c2f084ac9 - std::rt::lang_start::{{closure}}::h9f84df5707532228
  18:     0x626c2f3d547a - std::rt::lang_start_internal::h8fef16c8ee038552
  19:     0x626c2efe1862 - main
  20:     0x71921ff86ded - __libc_start_main
  21:     0x626c2efb41ea - _start
  22:                0x0 - <unknown>

source.tar.gz

reproducer:

sudo tar --same-owner --preserve-permissions -xf source.tar.gz
sudo chmod 400 nix -R
sudo chown root:root nix -R
uutils-cp -r --reflink=auto nix/store/dvh1x2m7gvp1iv5jjlvrf5ry5g3ay23k-source source

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions