@marcel91200 / caddy Mirror · read-only / commits / a6fc144e
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 02:15 UTC

logging: use the default file mode for dir_mode from_file (#8225)

Jay Hemnani committed Oct 16, 2026 at 17:56 UTC a6fc144e7538235e17b1121fa56dd1b34e54f1e7
2 files changed +22 -1
modules/logging/filewriter.go
+1 -1
@@ -206,7 +206,7 @@ func (fw FileWriter) OpenWriter() (io.WriteCloser, error) {
206 return nil, err
207 }
208 case "from_file":
209 - if err := mkdirAllFromFile(dirPath, os.FileMode(fw.Mode)); err != nil {
209 + if err := mkdirAllFromFile(dirPath, modeIfCreating); err != nil {
210 return nil, err
211 }
212 default:
modules/logging/filewriter_test.go
+21
@@ -506,6 +506,27 @@ func TestDirMode_FromFile(t *testing.T) {
506 if got := st2.Mode().Perm(); got != 0o700 {
507 t.Fatalf("dir perm = %o, want 0700", got)
508 }
509 +
510 + dir3 := filepath.Join(base, "logs3")
511 + fw3 := &FileWriter{
512 + Filename: filepath.Join(dir3, "app.log"),
513 + DirMode: "from_file",
514 + // no Mode: the file is created 0600 => dir 0700
515 + Roll: func() *bool { f := false; return &f }(),
516 + }
517 + w3, err := fw3.OpenWriter()
518 + if err != nil {
519 + t.Fatal(err)
520 + }
521 + _ = w3.Close()
522 +
523 + st3, err := os.Stat(dir3)
524 + if err != nil {
525 + t.Fatal(err)
526 + }
527 + if got := st3.Mode().Perm(); got != 0o700 {
528 + t.Fatalf("dir perm = %o, want 0700", got)
529 + }
530 }
531
532 func TestDirMode_ExplicitOctal(t *testing.T) {