twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
12.85k stars 477 forks source link

Umask from config file is not used #2609

Closed zroug closed 1 year ago

zroug commented 1 year ago

Describe the bug

Chezmoi ignores a umask that is set in the configuration file.

To reproduce

  1. Check that the default umask is less restrictive than desired.

    $ umask
    0022
  2. Set a more restrictive umask in the configuration file.

    $ cat .config/chezmoi/chezmoi.yaml 
    umask: 0o077
  3. Observe that Chezmoi does not honor the new umask.

    $ chezmoi diff
    diff --git a/file b/file
    old mode 40700
    new mode 40755

Expected behavior

Chezmoi should use the umask from the configuration file. So in the example above, the diff would be empty.

Output of command with the --verbose flag

Output is the same.

Output of chezmoi doctor

```console $ chezmoi doctor RESULT CHECK MESSAGE ok version v2.27.2, commit 882d0808feb1fc8112b411ed2216f31306656861, built at 2022-11-24T23:41:28Z, built by goreleaser ok latest-version v2.27.2 ok os-arch linux/amd64 (Fedora Linux 37.20221130.0 (Silverblue)) ok uname Linux l6zdz0 6.0.10-300.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Nov 26 16:55:13 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux ok go-version go1.19.3 (gc) ok executable ~/bin/chezmoi ok upgrade-method replace-executable ok config-file ~/.config/chezmoi/chezmoi.yaml, last modified 2022-11-29T19:42:35+01:00 warning source-dir ~/.local/share/chezmoi is a git working tree (dirty) ok suspicious-entries no suspicious entries warning working-tree ~/.local/share/chezmoi is a git working tree (dirty) ok dest-dir ~ is a directory ok umask 022 ok cd-command found /bin/bash ok cd-args /bin/bash info diff-command not set ok edit-command found /usr/bin/nano ok edit-args /usr/bin/nano ok git-command found /usr/bin/git, version 2.38.1 warning merge-command vimdiff not found in $PATH ok shell-command found /bin/bash ok shell-args /bin/bash info age-command age not found in $PATH ok gpg-command found /usr/bin/gpg, version 2.3.8 info pinentry-command not set info 1password-command op not found in $PATH info bitwarden-command bw not found in $PATH info gopass-command gopass not found in $PATH info keepassxc-command keepassxc-cli not found in $PATH info keepassxc-db not set info keeper-command keeper not found in $PATH info lastpass-command lpass not found in $PATH info pass-command pass not found in $PATH info passhole-command ph not found in $PATH info vault-command vault not found in $PATH info secret-command not set ```

Additional context

Above I used the output of chezmoi diff as an example, but the bug applies to chezmoi apply too.

twpayne commented 1 year ago

Thanks for spotting this! #2613 fixes it.