Fix process waiting and mode-enable robustness in sops.el#20
Open
ArthurHeymans wants to merge 2 commits into
Open
Fix process waiting and mode-enable robustness in sops.el#20ArthurHeymans wants to merge 2 commits into
ArthurHeymans wants to merge 2 commits into
Conversation
sops--run waited only for a sentinel-maintained flag before reading the process result. In interactive sessions the subprocess can exit before the sentinel has run, which leaves save-buffer spinning forever even though the sops command is already done. Wait while the process is live as well as while the sentinel flag is unset, then perform a final non-blocking output drain before reading stdout and stderr. Add a regression test that replaces the sentinel with a no-op to prove sops--run does not depend solely on that flag.
Manual sops-mode activation can happen after a file did not match the find-file prefilter, leaving the buffer full of ciphertext. Previously the mode installed encrypt-on-save hooks without decrypting first; a later revert or mode reset could drop those hooks and a normal save would write plaintext. On manual enable, verify the visited file is a SOPS file, refuse to overwrite modified buffer contents, decrypt the file, and then install the normal protections. On revert, reassert sops-mode state and restore local hooks after a successful decrypt so plaintext major-mode setup cannot leave the buffer unprotected. Add regression tests for manual activation, modified-buffer refusal, and revert hook restoration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two independent bugs are addressed in this PR: a potential infinite loop in
sops--runwhen a subprocess sentinel is delayed or never fires, and incomplete state management when manually enablingsops-modeon an already-open buffer.Process waiting fix (
sops--run)(process-live-p proc)in addition to the sentinel-setdoneflag, preventing an infinite spin if the sentinel is delayed or suppressed(accept-process-output proc 0 nil t)call after the loop to drain any remaining output that arrived between the last poll and process exitsops-test--run-does-not-require-sentinel-flag) that replaces the sentinel with a no-op and asserts the call completes within 2 secondsManual
sops-modeenable fixesuser-errorrather than silently overwriting unsaved edits with plaintextsops-modeandsops--stateare explicitly set to their correct values; previously the mode could be enabled with stale or missing statesops--revert-buffernow explicitly reinstallssops-mode,sops--state, andsops--restore-after-major-mode-changeafter a successful decrypt, guarding against major-mode setup that clears local variables duringsops--decrypt-buffer