mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
chown: follow symlinks correctly
This commit is contained in:
@@ -14,6 +14,13 @@ libc = "*"
|
||||
uucore = { path="../uucore" }
|
||||
walkdir = "0.1"
|
||||
|
||||
[dependencies.clippy]
|
||||
version = "*"
|
||||
optional = true
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
[[bin]]
|
||||
name = "chown"
|
||||
path = "main.rs"
|
||||
|
||||
+5
-2
@@ -8,6 +8,9 @@
|
||||
// file that was distributed with this source code.
|
||||
//
|
||||
|
||||
#![cfg_attr(feature="clippy", feature(plugin))]
|
||||
#![cfg_attr(feature="clippy", plugin(clippy))]
|
||||
|
||||
extern crate libc;
|
||||
use libc::{uid_t, gid_t, c_char, c_int};
|
||||
|
||||
@@ -336,7 +339,7 @@ impl Chowner {
|
||||
fn dive_into<P: AsRef<Path>>(&self, root: P) -> i32 {
|
||||
let mut ret = 0;
|
||||
let root = root.as_ref();
|
||||
let follow = self.bit_flag & FTS_LOGICAL != 0;
|
||||
let follow = self.dereference || self.bit_flag & FTS_LOGICAL != 0;
|
||||
for entry in WalkDir::new(root).follow_links(follow).min_depth(1) {
|
||||
let entry = unwrap!(entry, e, {
|
||||
ret = 1;
|
||||
@@ -356,7 +359,7 @@ impl Chowner {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = self.wrap_chown(path, &meta, true);
|
||||
ret = self.wrap_chown(path, &meta, follow);
|
||||
}
|
||||
ret
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user