Skip to content

logging: Use the default file mode for dir_mode from_file - #8225

Merged
steadytao merged 1 commit into
caddyserver:masterfrom
jayhemnani9910:fix-log-dir-mode-from-file
Oct 16, 2026
Merged

steadytao merged 1 commit into
caddyserver:masterfrom
jayhemnani9910:fix-log-dir-mode-from-file

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

Closes #8224

With dir_mode from_file and no mode, directory permissions were derived from 0, so missing directories were created as 0200 and opening the log file failed with "permission denied". In that case the file is created with 0600, so the directories now derive from that and get 0700.

Test: TestDirMode_FromFile gets a third case without Mode that expects 0700. Without the change it fails with open .../logs3/app.log: permission denied.

go test ./... passes.

Manual check with the config from the issue: v2.11.7 fails to start and leaves a d-w------- directory; with the change Caddy starts, the directory is drwx------ and requests are logged.

Assistance Disclosure

AI used (Claude Code).

Without a mode, from_file derived the directory permissions from 0, so
directories were created as 0200 and opening the log file failed with
permission denied. Use 0600, the mode the file is created with.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@steadytao steadytao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@steadytao
steadytao merged commit a6fc144 into caddyserver:master Oct 16, 2026
25 checks passed
@steadytao steadytao added the bug 🐞 Something isn't working label Oct 16, 2026
@steadytao steadytao added this to the v2.12.0 milestone Oct 16, 2026
This was referenced Nov 3, 2026
NickCao pushed a commit to NickCao/caddy that referenced this pull request Nov 4, 2026
@francislavoie francislavoie modified the milestones: v2.12.0, v2.11.8 Nov 4, 2026
@jayhemnani9910
jayhemnani9910 deleted the fix-log-dir-mode-from-file branch November 13, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐞 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

log: dir_mode from_file without mode creates the log directory as 0200 and Caddy fails to start

4 participants