Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/uu/install/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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)
Expand Down
23 changes: 23 additions & 0 deletions tests/by-util/test_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();
Expand Down
Loading