Fix InitWithTemplate mkdir permissions inconsistency (0o700 vs 0o777) #9

Closed
opened 2026-09-20 15:05:21 +00:00 by agent · 0 comments
Member

Problem

core/load.go:75 uses 0o700 for os.MkdirAll in InitWithTemplate:

if err := os.MkdirAll(filepath.Dir(a.UserPath()), 0o700); err != nil {

But core/write.go:50 uses 0o777:

if err := os.MkdirAll(filepath.Dir(path), 0o777); err != nil {

The 0o700 in InitWithTemplate is overly restrictive — it creates directories that only the owner can access, which breaks scenarios where the config directory is shared (e.g. system-wide configs, Docker volumes, or shared dev environments). The 0o777 in WriteFile is correct — it respects the process umask.

Fix

Change core/load.go:75 from 0o700 to 0o777:

if err := os.MkdirAll(filepath.Dir(a.UserPath()), 0o777); err != nil {

Files

  • core/load.go — one-line change

Verification

Existing TestInitWithTemplate and TestInitWithTemplateReadOnlyDir tests should still pass.

## Problem `core/load.go:75` uses `0o700` for `os.MkdirAll` in `InitWithTemplate`: ```go if err := os.MkdirAll(filepath.Dir(a.UserPath()), 0o700); err != nil { ``` But `core/write.go:50` uses `0o777`: ```go if err := os.MkdirAll(filepath.Dir(path), 0o777); err != nil { ``` The `0o700` in `InitWithTemplate` is overly restrictive — it creates directories that only the owner can access, which breaks scenarios where the config directory is shared (e.g. system-wide configs, Docker volumes, or shared dev environments). The `0o777` in `WriteFile` is correct — it respects the process umask. ## Fix Change `core/load.go:75` from `0o700` to `0o777`: ```go if err := os.MkdirAll(filepath.Dir(a.UserPath()), 0o777); err != nil { ``` ## Files - `core/load.go` — one-line change ## Verification Existing `TestInitWithTemplate` and `TestInitWithTemplateReadOnlyDir` tests should still pass.
agent closed this issue 2026-09-20 15:49:32 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
residual/config#9
No description provided.