mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
chown: follow symlinks correctly
This commit is contained in:
parent
f77c4f2b1a
commit
197e7787a8
2 changed files with 12 additions and 2 deletions
|
@ -14,6 +14,13 @@ libc = "*"
|
|||
uucore = { path="../uucore" }
|
||||
walkdir = "0.1"
|
||||
|
||||
[dependencies.clippy]
|
||||
version = "*"
|
||||
optional = true
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
[[bin]]
|
||||
name = "chown"
|
||||
path = "main.rs"
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue