mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge pull request #9254 from akretz/install_ignore_umask
install: ignore umask
This commit is contained in:
@@ -25,7 +25,6 @@ use uucore::display::Quotable;
|
||||
use uucore::entries::{grp2gid, usr2uid};
|
||||
use uucore::error::{FromIo, UError, UResult, UUsageError};
|
||||
use uucore::fs::dir_strip_dot_for_creation;
|
||||
use uucore::mode::get_umask;
|
||||
use uucore::perms::{Verbosity, VerbosityLevel, wrap_chown};
|
||||
use uucore::process::{getegid, geteuid};
|
||||
#[cfg(feature = "selinux")]
|
||||
@@ -339,7 +338,7 @@ fn behavior(matches: &ArgMatches) -> UResult<Behavior> {
|
||||
|
||||
let specified_mode: Option<u32> = if matches.contains_id(OPT_MODE) {
|
||||
let x = matches.get_one::<String>(OPT_MODE).ok_or(1)?;
|
||||
Some(mode::parse(x, considering_dir, get_umask()).map_err(|err| {
|
||||
Some(mode::parse(x, considering_dir, 0).map_err(|err| {
|
||||
show_error!(
|
||||
"{}",
|
||||
translate!("install-error-invalid-mode", "error" => err)
|
||||
|
||||
@@ -243,6 +243,29 @@ fn test_install_mode_symbolic() {
|
||||
assert_eq!(0o100_003_u32, PermissionsExt::mode(&permissions));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_install_mode_symbolic_ignore_umask() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let dir = "target_dir";
|
||||
let file = "source_file";
|
||||
let mode_arg = "--mode=+w";
|
||||
|
||||
at.touch(file);
|
||||
at.mkdir(dir);
|
||||
ucmd.arg(file)
|
||||
.arg(dir)
|
||||
.arg(mode_arg)
|
||||
.umask(0o022)
|
||||
.succeeds()
|
||||
.no_stderr();
|
||||
|
||||
let dest_file = &format!("{dir}/{file}");
|
||||
assert!(at.file_exists(file));
|
||||
assert!(at.file_exists(dest_file));
|
||||
let permissions = at.metadata(dest_file).permissions();
|
||||
assert_eq!(0o100_222_u32, PermissionsExt::mode(&permissions));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_install_mode_failing() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
Reference in New Issue
Block a user