fix: imported configs must stay readable by the gui #50
Loading…
Reference in a new issue
No description provided.
Delete branch "mysticalsoap/fix/import-file-modes"
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?
Problem
Pressing Modify on a custom-provider server crashed the whole GUI (core dump). Two bugs compounding, both surfaced while manually testing #49's modify-server flow:
copy_certssetsos.umask(0o077)for the credentials file but restores it only at the very end of the function — after every config copy.shutil.copyfilecreates fresh destination files, so every custom-provider config imported since the beginning has landed inROOTDIRas0600, unreadable by the GUI.modify_serverhad no guard for an unreadable config, and PyQt5 aborts the process when an exception escapes a slot — so thePermissionErrorfrom the dialog's config display became a core dump.Fix
.ovpn/.conf) get0644unless they inline a personal secret (<key>,<pkcs12>,<secret>,<auth-user-pass>,<tls-crypt-v2>), which keeps them0600along with keys/certs — openvpn runs as root and reads them regardless.<tls-auth>/<tls-crypt>deliberately don't count: providers ship the same HMAC key in every bulk config, and treating it as a secret would lock the GUI's own modify dialog out of most imports. Source-file modes no longer decide what lands inROOTDIReither. A config kept at0600can't be opened in the modify dialog — that's the graceful notification path below, not a crash.openvpn.confchmod loses its stray exec bits (0655→0644).modify_servercatchesOSErrorand notifies instead of crashing.Verification
TestImportedFileModesintests/test_update.py: a staged custom import asserts a tls-crypt-only config lands0644, a config with an inlined<key>lands0600, keys and the auth file land0600(with source modes deliberately set to mislead), and that the umask is restored aftercopy_certs. Logic hand-verified locally (pytest runs in CI).PermissionErroron a0600imported config, followed by the core dump).Assisted-by: claude-fable-5
7bc0a5c874eb536fce2c