uutils / uutils/coreutils

install: ancestor directories respect process umask instead of using fixed 0755 (diverges from GNU)

Open
#12,714 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

U - install
Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

Description

When install -D or install -d creates ancestor directories, it passes DEFAULT_MODE=0755 to the underlying mkdirat/mkdir syscall, which still has the process umask applied by the kernel. GNU install instead calls umask(0) at startup, so ancestor directories are always created with exactly 0755 regardless of the caller's umask.

Impact

For any umask that has bits set within the 0755 pattern — e.g. 0027, 0077, 0111 — uutils creates ancestor directories with a different mode than GNU:

umask GNU install (ancestors) uutils (ancestors)
0022 0755 0755
0002 0755 0755
0027 0755 0750
0077 0755 0700
0111 0755 0644

Note: umask 0002 (the trigger for issue #11363) coincidentally does not change 0755 because it only strips world-write, which 0755 does not have — so that specific report was caused by a broken test rather than this bug. However, the underlying behavioral divergence is real.

GNU behavior

From install.c in GNU coreutils:

  • main() calls umask(0) early, before any file operations
  • make_ancestor() calls mkdir(component, DEFAULT_MODE) where DEFAULT_MODE = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH (0755)
  • Because umask is 0, ancestor directories always get exactly 0755

Affected code

  • src/uu/install/src/install.rs: both code paths (directory() line ~498 and standard() line ~687) create ancestor directories without zeroing umask first
  • src/uucore/src/lib/features/safe_traversal.rs: create_dir_all_safe documents that "the actual mode will be modified by the process umask"

Fix

Zero the process umask early in install's uumain (unix only), matching GNU's approach. uucore::mode already uses rustix::process::umask internally for get_umask(); a zero_umask() helper can be exported from there.

Related: #11363, PR #12713

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/uu/install/src/install.rs, especially uumain and the directory() and standard() paths, then read the umask handling in src/uucore/src/lib/features/safe_traversal.rs and uucore::mode. Verify the install behavior under umasks such as 0027, 0077, and 0111; done means ancestor directories match GNU's 0755 behavior on Unix without changing unrelated paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.