logging: add DirMode options and propagate FileMode to rotations#7335
Merged
francislavoie merged 2 commits intocaddyserver:masterfrom Feb 23, 2026
Merged
logging: add DirMode options and propagate FileMode to rotations#7335francislavoie merged 2 commits intocaddyserver:masterfrom
francislavoie merged 2 commits intocaddyserver:masterfrom
Conversation
This was referenced Nov 3, 2025
Member
|
Thanks! Please don't forget to sign the CLA |
Contributor
Author
|
I just signed 👍 |
8a069e3 to
5d73a30
Compare
francislavoie
approved these changes
Feb 23, 2026
Member
|
Sorry for the delay! Looks great to me. I added another commit to fixup an issue with |
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.
Summary
This PR enhances the
FileWriterlogging module to give users explicit control over directory creation permissions and ensures that rotated log files inherit the correct file mode from configuration. Closes #7314Changes
Added
DirModeoption toFileWriter:"inherit"→ copies the nearest existing parent directory’s permissions, normalizingr→xfor directories."from_file"→ derives directory permissions from the file’s mode (e.g.,0644 → 0755,0600 → 0700)."0755") → directly specify directory permissions.0700(same as before, ensuring backward compatibility).Improved permission handling:
DirModeis set, directories are created using the requested mode.normalizeDirPerm()to ensure directories with read bits also gain execute bits (so they’re traversable).Propagated file mode to timberjack:
FileMode: os.FileMode(fw.Mode)to the embeddedtimberjack.Logger.Security-conscious defaults:
0700directories,0600files).r→xnormalization applies only to directories — not to files.Tests Added
Extended test coverage in:
filewriter_test.go(Unix)filewriter_test_window.go(Windows)Added cases for:
DirModevalues:inherit,from_file, explicit octal, and default.dir_modefrom the Caddyfile.Assistance Disclosure
AI was used to generate this PR summery and also to expand some tests I wrote. Everything was reviewed by me.