Set umask 002 system-wide instead of per-user shell rc files#53
Merged
Conversation
40257d8 to
d8b27b8
Compare
Drush (run by tooling) was writing private://logs/debug-*.log as 644
owned by vscode:www-data, so the apache www-data web server couldn't
append to them and pages 500'd.
The previous approach appended `umask 002` to per-user shell rc files
(~/.zshrc, ~/.bashrc) and relied on pam_umask. That's fragile here:
- VS Code-spawned terminals and `exec`s don't open a PAM session, so
pam_umask never fires for them.
- Developers commonly symlink ~/.zshrc / ~/.bashrc from a personal
dotfiles repo, which overwrites our per-user edits.
Set umask 002 in the system shell files instead, which are immune to
both problems:
- /etc/zsh/zshenv - every zsh invocation (login/non-login,
interactive/not); covers the drush/tooling path
- /etc/bash.bashrc - interactive non-login bash (VS Code terminals)
- /etc/profile.d/umask.sh - login shells (sh and bash)
The per-user appends in devcontainer_on_create are dropped as redundant;
only the in-process `umask 002` is kept, since the system-wide config
isn't in effect in that shell on the very first run (before the log file
that drush deploy creates). pam_umask is kept as a backstop for real PAM
sessions (ssh, su, cron).
Non-interactive bash (`bash -c`, scripts) has no equivalent hook, but
that matches the previous behavior and tooling runs under zsh, which
/etc/zsh/zshenv covers completely.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
d8b27b8 to
681641a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Drush (run by tooling) writes
private://logs/debug-*.logas644owned byvscode:www-data, so the apachewww-dataweb server can't append to them → pages 500 (notably/user/login, which breaks Cypress in abefore allhook).Why the per-user approach was fragile
The previous setup appended
umask 002to per-user shell rc files (~/.zshrc,~/.bashrc) and relied onpam_umask. Two things defeat that in this devcontainer:execs don't open a PAM session, sopam_umasknever fires for them — that's why the shell-rc appends existed in the first place.~/.zshrc/~/.bashrcfrom a personal dotfiles repo (e.g. applied afteronCreate), which overwrites our per-user edits. The umask line silently disappears.Change: set it system-wide
System shell files are immune to both problems, so set
umask 002there instead:/etc/zsh/zshenv/etc/bash.bashrc/etc/profile.d/umask.shThe per-user appends in
devcontainer_on_createare dropped as redundant. Only the in-processumask 002is kept, because the system-wide config isn't in effect in that shell on the very first run (before the log file thatdrush deploycreates).pam_umaskis kept as a backstop for real PAM sessions (ssh, su, cron).Caveat (not a regression)
Non-interactive bash (
bash -c,#!/bin/bashscripts) has no equivalent hook — bash has nothing likezshenv. This matches the previous behavior (~/.bashrconly covers interactive bash too), and the actual tooling path runs under zsh, which/etc/zsh/zshenvcovers completely.Verification
Reproduced in a running container with
~/.zshrcsymlinked to a personal dotfiles repo: non-login zsh ran at022and drush wrote644logs. Withumask 002reaching the shell, interactive zsh and drush run at002and drush-created log files come out664(vscode:www-data), which the web server can append to./etc/bash.bashrcconfirmed sourced by interactive non-login bash, and/etc/profile.d/*.shsourced by/etc/profile, on themcr.microsoft.com/devcontainers/php:8.3base image.🤖 Generated with Claude Code