fix: triage the unwritable config dir remedy by cause

The chown hint is only correct when another account created files
inside the current user's own home. When a leaked HOME or
XDG_CONFIG_HOME points at another user's home (e.g. sudo -u on GitHub
runners), following it would chown that user's directory and brick
their pmg instead. Classify the failure against the passwd home,
which the leaked environment cannot influence, and prescribe:

- dir inside own home: restore ownership with chown
- dir outside own home: fix the leaked environment, never chown
- explicit PMG_CONFIG_DIR: make it writable

Used by both the fatal event-log error and the doctor check, and the
docs troubleshooting now carries the same two-case triage.
This commit is contained in:
Sahilb315
2026-07-14 03:56:07 +05:30
parent de0fa41852
commit cd9b45b3bc
6 changed files with 100 additions and 12 deletions
+1 -1
View File
@@ -229,7 +229,7 @@ func eventlogInitError(err error) error {
return usefulerror.NewUsefulError().
WithCode(errcodes.PermissionDenied).
WithHumanError("event logging is required but its directory is not writable").
WithHelp(fmt.Sprintf("If a root or sudo run created it, restore ownership: sudo chown -R $(id -un) %s", config.Get().ConfigDir())).
WithHelp(config.UnwritableConfigDirRemedy(config.Get().ConfigDir())).
Wrap(err)
}
return usefulerror.NewUsefulError().