Do not clobber a symlinked config file on save #90
No reviewers
Labels
No labels
Bug
BuildIssue
Claude-fixed
Enhancement
In Progress
Low priority
On Hold
Rejected
Security
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
keyop-go/nfq_forwarder!90
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue89_symlink_write"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #89.
See the issue comment for the root-cause writeup. Summary:
atomicWriteConfigFilewrites via a temp file plusos.Renamefor atomicity, butrename(2)does not follow a symlink at the destination - it replaces whatever is there unconditionally. If--configpointed at a symlink, a web UI save destroyed it and left a plain regular file in its place.Fix: resolve the real target via
filepath.EvalSymlinksonce at the top (falling back to the given path if resolution fails, e.g. a genuinely missing file) and operate on that resolved path throughout - permission lookup, temp file directory, and the final rename target. This also fixes a related latent bug: the temp file needs to live in the same directory as the real rename target, not necessarily the symlink's own directory, oros.Renamecould fail outright withEXDEVeven before the clobbering problem.Tested against a real symlink (same directory, and separately across two different temp directories to exercise the cross-filesystem-safe temp-file placement), plus an end-to-end test through the real HTTP save handler. Confirmed all three tests actually fail without the fix (by temporarily reverting it and re-running) before restoring it, not just that they pass with it.
make lint/make testclean.LGTM