From 5e645a7be7ce79519ddd1cb057a196b8505f9b20 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 25 Jan 2023 23:34:31 +0530 Subject: [PATCH] Fix ssh kitten not working on FreeBSD Apparently on FreeBSD one cannot unlink shared mem if it is not created with write permissions. Adding IWRITE to the permissions when creating the shared memory is harmless. It means any process running as the user can either write to the file or delete it. Deleting was already possible except on FreeBSD. As for writing, it's needed on FreeBSD for shared memory to be useable at all, and since processes running as the user can already completely access all their data, kitty config files, tty pipes, etc. allowing them to write to the SHM used here doesnt grant any significant new capability, since they could just write to ssh.conf in the kitty config folder to get the ssh kitten to do whatever they like. Fixes #5928 --- docs/changelog.rst | 2 ++ kittens/ssh/utils.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index c2420ad0c..55a077b9d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -95,6 +95,8 @@ Detailed list of changes - Fix using :opt:`cursor` = ``none`` not working on text that has reverse video (:iss:`5897`) +- Fix ssh kitten not working on FreeBSD (:iss:`5928`) + 0.26.5 [2022-11-07] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kittens/ssh/utils.py b/kittens/ssh/utils.py index fcae4e24b..c501d165e 100644 --- a/kittens/ssh/utils.py +++ b/kittens/ssh/utils.py @@ -83,7 +83,7 @@ def create_shared_memory(data: Any, prefix: str) -> str: from kitty.shm import SharedMemory db = json.dumps(data).encode('utf-8') - with SharedMemory(size=len(db) + SharedMemory.num_bytes_for_size, mode=stat.S_IREAD, prefix=prefix) as shm: + with SharedMemory(size=len(db) + SharedMemory.num_bytes_for_size, prefix=prefix) as shm: shm.write_data_with_size(db) shm.flush() atexit.register(shm.unlink)