Skip to content

dynamic host volumes: apply requested perms#27068

Merged
pkazmierczak merged 2 commits intohashicorp:mainfrom
lgfa29:fix-dynamic-host-volume-mkdir-perm
Nov 12, 2025
Merged

dynamic host volumes: apply requested perms#27068
pkazmierczak merged 2 commits intohashicorp:mainfrom
lgfa29:fix-dynamic-host-volume-mkdir-perm

Conversation

@lgfa29
Copy link
Copy Markdown
Contributor

@lgfa29 lgfa29 commented Nov 9, 2025

Description

The mkdir dynamic host volume plugin uses the os.MkdirAll() function to create the host volume directory, but the permissions passed are affected by the user's umask, which can result in unexpected directory permissions.

For example, with the common default umask of 022, creating a dynamic host volume with mode = "0777" results in a directory with permissions set to 0755.

Testing & Reproduction steps

  1. Check user umask is not 000.
  2. Create a dynamic host volume using the mkdir plugin with mode = "0777".
  3. Verify the host volume directory permission is 0777.

Links

The permission bits perm (before umask) are used for all directories that MkdirAll creates.

https://pkg.go.dev/os#MkdirAll

Closes #26190

Contributor Checklist

  • Changelog Entry If this PR changes user-facing behavior, please generate and add a
    changelog entry using the make cl command.
  • Testing Please add tests to cover any new functionality or to demonstrate bug fixes and
    ensure regressions will be caught.
  • Documentation If the change impacts user-facing functionality such as the CLI, API, UI,
    and job configuration, please update the Nomad website documentation to reflect this. Refer to
    the website README for docs guidelines. Please also consider whether the
    change requires notes within the upgrade guide.

Reviewer Checklist

  • Backport Labels Please add the correct backport labels as described by the internal
    backporting document.
  • Commit Type Ensure the correct merge method is selected which should be "squash and merge"
    in the majority of situations. The main exceptions are long-lived feature branches or merges where
    history should be preserved.
  • Enterprise PRs If this is an enterprise only PR, please add any required changelog entry
    within the public repository.
  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

The `mkdir` dynamic host volume plugin uses the `os.MkdirAll()` function
to create the host volume directory, but the permissions passed are
affected by the user's `umask`, which can result in unexpected directory
permissions.

For example, with the common default `umask` of `022`, creating a
dynamic host volume with `perms = "0777"` results in a directory with
permissions set to `0755`.
@lgfa29 lgfa29 requested review from a team as code owners November 9, 2025 02:03
Copy link
Copy Markdown
Contributor

@pkazmierczak pkazmierczak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the contribution, Luiz!

@pkazmierczak pkazmierczak moved this from Needs Triage to In Progress in Nomad - Community Issues Triage Nov 11, 2025
@pkazmierczak pkazmierczak self-assigned this Nov 11, 2025
@pkazmierczak pkazmierczak added backport/ent/1.8.x+ent Changes are backported to 1.8.x+ent backport/ent/1.10.x+ent backport to 1.10.x+ent release line backport/1.11.x backport to 1.11.x release line and removed backport/ent/1.8.x+ent Changes are backported to 1.8.x+ent labels Nov 12, 2025
@pkazmierczak pkazmierczak merged commit 8b4c265 into hashicorp:main Nov 12, 2025
40 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Nomad - Community Issues Triage Nov 12, 2025
pkazmierczak pushed a commit that referenced this pull request Nov 12, 2025
The `mkdir` dynamic host volume plugin uses the `os.MkdirAll()` function
to create the host volume directory, but the permissions passed are
affected by the user's `umask`, which can result in unexpected directory
permissions.

For example, with the common default `umask` of `022`, creating a
dynamic host volume with `perms = "0777"` results in a directory with
permissions set to `0755`.
pkazmierczak pushed a commit that referenced this pull request Nov 12, 2025
…1.11.x (#27087)

* no-op commit due to failed cherry-picking

* dynamic host volumes: apply requested perms (#27068)

The `mkdir` dynamic host volume plugin uses the `os.MkdirAll()` function
to create the host volume directory, but the permissions passed are
affected by the user's `umask`, which can result in unexpected directory
permissions.

For example, with the common default `umask` of `022`, creating a
dynamic host volume with `perms = "0777"` results in a directory with
permissions set to `0755`.

---------

Co-authored-by: temp <temp@hashicorp.com>
Co-authored-by: Luiz Aoqui <luiz@hashicorp.com>
@github-actions
Copy link
Copy Markdown

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport/ent/1.10.x+ent backport to 1.10.x+ent release line backport/1.11.x backport to 1.11.x release line

Projects

Development

Successfully merging this pull request may close these issues.

Dynamic hostvolume setting directory permissions

3 participants