edit-in-kitty: Fix running edit-in-kitty with elevated privileges to edit a restricted file not working

This commit is contained in:
Kovid Goyal 2023-05-07 09:36:16 +05:30
parent 79cd6f38fe
commit 474244268c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 1 deletions

View File

@ -57,6 +57,8 @@ Detailed list of changes
- kitty +open: Ask for permission before executing script files that are not marked as executable. This prevents accidental execution - kitty +open: Ask for permission before executing script files that are not marked as executable. This prevents accidental execution
of script files via MIME type association from programs that unconditionally "open" attachments/downloaded files. of script files via MIME type association from programs that unconditionally "open" attachments/downloaded files.
- edit-in-kitty: Fix running edit-in-kitty with elevated privileges to edit a restricted file not working (:disc:`6245`)
0.28.1 [2023-04-21] 0.28.1 [2023-04-21]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -715,7 +715,7 @@ class EditCmd:
self.is_local_file = False self.is_local_file = False
with suppress(OSError): with suppress(OSError):
st = os.stat(self.file_localpath) st = os.stat(self.file_localpath)
self.is_local_file = (st.st_dev, st.st_ino) == self.file_inode self.is_local_file = (st.st_dev, st.st_ino) == self.file_inode and os.access(self.file_localpath, os.W_OK | os.R_OK)
if not self.is_local_file: if not self.is_local_file:
import tempfile import tempfile
self.tdir = tempfile.mkdtemp() self.tdir = tempfile.mkdtemp()