Ticket #3163 (new enhancement)
Several improvements in editor saving behavior
Reported by: | CyberShadow | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | Future Releases |
Component: | mcedit | Version: | master |
Keywords: | Cc: | egmont@… | |
Blocked By: | Blocking: | ||
Branch state: | no branch | Votes for changeset: |
Description
I have created a pull request on GitHub? a week ago, kindly review it:
https://github.com/MidnightCommander/mc/pull/32
Change History
comment:3 Changed 11 years ago by egmont
- Cc egmont@… added
One more problematic case occurred to me with sudo. When you can't write a file, it's not necessarily because the it's owned by root. It can be that the file belongs to the user but has no write permissions. It could be that the file belongs to another (non-root) user, whom should we sudo then (and if we sudo to root, how would we set the file's owner/group)? It could be that the file belongs to someone else over a network filesystem, in that case sudo doesn't help either. I'm not saying it's impossible, I'm just saying it's probably terribly complicated and error prone and probably the wrong approach the address the initial problem.
Just a random guy's opinion:
Invoking external sudo (a file manager calling an external command to copy) looks ugly and fragile to me. What if sudo is configured not to work for that user? What if an error occurs during execution, how will it be propagated to the user? (Would you read back the file to verify that it was copied successfully?) Could you be sure that permissions, symlinks, hardlinks, whatever are maintained exactly as if mcedit saved the file? How would you handle creating a backup according to mcedit's preference?
In my opinion, it would be cleaner if mcedit warned you that the file is not writable when you opened the file, or when attempted to first modify it. Or if it set the buffer read-only. You could immediately quit and go for "sudo mcedit" or similar.