fwmechanic / k_edit

K Editor for Win32 and Linux
GNU General Public License v3.0
11 stars 0 forks source link

Linux: lack of file write permissions does not impede saving modified files #1

Open fwmechanic opened 9 years ago

fwmechanic commented 9 years ago

Default K file-backup modes (undel, bak) first move (rename) the original file to some backup-filename, then write an entirely new instance of the originally-named file. The permissions of the original instance of the file cannot prevent it from being renamed (only directory permissions can prevent renaming (or deletion, for that matter)).

This is troublesome when using an archaic VCS which relies on file permissions defaulting to 'no-write' to force users to checkout files from the VCS before editing them: with K, you just start editing, never having reason to notice that you should have first checked the file out from VCS.

This presents an interesting dilemma, since the described backup process is cleaner (the original file is never written, merely renamed, so the integrity of it's content is less subject to corruption); a backup process specifically designed to be impeded by lack of write permission, would (AFAICT) necessarily involve copying all of the original file bytes to a new (backup) file, then overwriting the file's content in situ.

What to do...?

And a closely related issue: new file instances created by the above-described move-then-write-new process have owner (uid/gid) == that of the K process. When editing files as root, this can easily lead to file ownership being corrupted (unintentionally changed). Solution vectors: