mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
feature(install): move chown functions into uucore and have install owner support use it
This commit is contained in:
parent
015e18731f
commit
55c660b986
7 changed files with 167 additions and 103 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::common::util::*;
|
||||
use rust_users::*;
|
||||
|
||||
extern crate chown;
|
||||
// pub use self::uu_chown::*;
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_passgrp {
|
||||
|
@ -378,4 +378,17 @@ fn test_root_preserve() {
|
|||
assert!(result
|
||||
.stderr
|
||||
.contains("chown: it is dangerous to operate recursively"));
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_big_p() {
|
||||
if get_effective_uid() != 0 {
|
||||
new_ucmd!()
|
||||
.arg("-RP")
|
||||
.arg("bin")
|
||||
.arg("/proc/self/cwd")
|
||||
.fails()
|
||||
.stderr_is(
|
||||
"chown: changing ownership of '/proc/self/cwd': Operation not permitted (os error 1)\n",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::common::util::*;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use rust_users::*;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
#[test]
|
||||
fn test_install_help() {
|
||||
|
@ -227,6 +227,25 @@ fn test_install_target_new_file_with_group() {
|
|||
assert!(at.file_exists(&format!("{}/{}", dir, file)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_install_target_new_file_with_owner() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let file = "test_install_target_new_filer_file_j";
|
||||
let dir = "test_install_target_new_file_dir_j";
|
||||
let uid = get_effective_uid();
|
||||
|
||||
at.touch(file);
|
||||
at.mkdir(dir);
|
||||
ucmd.arg(file)
|
||||
.arg("--owner")
|
||||
.arg(uid.to_string())
|
||||
.arg(format!("{}/{}", dir, file))
|
||||
.succeeds()
|
||||
.no_stderr();
|
||||
|
||||
assert!(at.file_exists(file));
|
||||
assert!(at.file_exists(&format!("{}/{}", dir, file)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_install_target_new_file_failing_nonexistent_parent() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue