Skip to content

Commit 23870b5

Browse files
committed
Interactive prompt mode fetch should not follow symlinks
1 parent 57bc762 commit 23870b5

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎src/uu/mv/src/mv.rs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,9 +1591,8 @@ fn is_empty_dir(path: &Path) -> bool {
15911591
fn is_writable(path: &Path) -> (bool, Option<u32>) {
15921592
if let Ok(metadata) = path.symlink_metadata() {
15931593
let mode = metadata.permissions().mode();
1594-
let is_symlink = metadata.is_symlink();
1595-
// Check if user write bit is set or target is symlink
1596-
((mode & 0o200) != 0 || is_symlink, Some(mode))
1594+
// Check if user write bit is set
1595+
((mode & 0o200) != 0, Some(mode))
15971596
} else {
15981597
(false, None) // If we can't get metadata, prompt user to be safe
15991598
}
@@ -1612,7 +1611,7 @@ fn is_writable(path: &Path) -> (bool, Option<u32>) {
16121611
#[cfg(unix)]
16131612
fn get_interactive_prompt(to: &Path, cached_mode: Option<u32>) -> String {
16141613
// Use cached mode if available, otherwise fetch it
1615-
let mode = cached_mode.or_else(|| to.metadata().ok().map(|m| m.permissions().mode()));
1614+
let mode = cached_mode.or_else(|| to.symlink_metadata().ok().map(|m| m.permissions().mode()));
16161615
if let Some(mode) = mode {
16171616
let file_mode = mode & 0o777;
16181617
// Check if file is not writable by user

0 commit comments

Comments
 (0)